sapling/eden/integration/hg/grep_test.py
Adam Simpkins ef04ccf546 replace a bunch of pyre-fixme comments with pyre-ignoree
Summary:
D17135557 added a bunch of `pyre-fixme` comments to the EdenFS integration
tests for cases where Pyre cannot detect that some attributes are initialized
by the test case `setUp()` method.

It looks like Pyre's handling of `setUp()` is somewhat incorrect: it looks
like if a class has a `setUp()` method this currently suppresses all
uninitialized attribute errors (even if some attributes really are never
initialized).  However, Pyre does not detect `setUp()` methods inherited from
parent classes, and always warns about uninitialized attributes in this case
even they are initialized.

Lets change these comments from `pyre-fixme` to `pyre-ignore` since this
appears to be an issue with Pyre rather than with this code.  T62487924 is
open to track adding support for annotating custom constructor methods, which
might help here.  I've also posted in Pyre Q&A about incorrect handling of
`setUp()` in derived classes.

Reviewed By: grievejia

Differential Revision: D19963118

fbshipit-source-id: 9fd13fc8665367e0780f871a5a0d9a8fe50cc687
2020-02-24 18:55:19 -08:00

64 lines
2.2 KiB
Python

#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from textwrap import dedent
from eden.integration.lib import hgrepo
from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test
# pyre-ignore[13]: T62487924
class GrepTest(EdenHgTestCase):
def populate_backing_repo(self, repo: hgrepo.HgRepository) -> None:
repo.write_file("file_in_root.txt", "\n".join(["apple", " banana", "cat"]))
repo.write_file("d1/d2/afile.txt", "\n".join(["banana", " banana"]))
repo.write_file("d1/d2/bfile.txt", "\n".join([" banana", "cat", "dog"]))
repo.commit("Initial commit.")
def test_grep_file(self) -> None:
stdout = self.hg("grep", "-n", "banana", "file_in_root.txt")
self.assertEqual("file_in_root.txt:2: banana\n", stdout)
def test_grep_directory_from_root(self) -> None:
stdout = self.hg("grep", "-n", "banana", "d1/d2")
expected = dedent(
"""\
d1/d2/afile.txt:1:banana
d1/d2/afile.txt:2: banana
d1/d2/bfile.txt:1: banana
"""
)
self.assertEqual(expected, stdout)
def test_grep_directory_from_subdirectory(self) -> None:
stdout = self.hg("grep", "-n", "banana", "d2", cwd=self.get_path("d1"))
expected = dedent(
"""\
d2/afile.txt:1:banana
d2/afile.txt:2: banana
d2/bfile.txt:1: banana
"""
)
self.assertEqual(expected, stdout)
def test_grep_that_does_not_match_anything(self) -> None:
with self.assertRaises(hgrepo.HgError) as context:
self.hg("grep", "NOT IN THERE")
self.assertEqual(b"", context.exception.stdout)
self.assertEqual(b"", context.exception.stderr)
self.assertEqual(123, context.exception.returncode)
def test_grep_that_does_not_match_anything_in_directory(self) -> None:
with self.assertRaises(hgrepo.HgError) as context:
self.hg("grep", "NOT IN THERE", "d1")
self.assertEqual(b"", context.exception.stdout)
self.assertEqual(b"", context.exception.stderr)
self.assertEqual(123, context.exception.returncode)