-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Python 3.12 seems to have some changes incompatible with pyannotate 1.2.0:
[ 20s] =========================== short test summary info ============================
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_callee_star_args
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_caller_star_args
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_recursive_function
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_run_a_bunch_of_tests
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_star_star_args
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_type_collection_on_main_thread
[ 20s] FAILED pyannotate_runtime/tests/test_collect_types.py::TestCollectTypes::test_yield_empty
[ 20s] FAILED tests/integration_test.py::IntegrationTest::test_package - AssertionEr...
[ 20s] FAILED tests/integration_test.py::IntegrationTest::test_simple - AssertionErr...
[ 20s] FAILED tests/integration_test.py::IntegrationTest::test_subdir - AssertionErr...
[ 20s] FAILED tests/integration_test.py::IntegrationTest::test_subdir_w_class - Asse...
[ 20s] =================== 11 failed, 74 passed, 1 warning in 1.48s ===================
All details:
Details
[ 20s] =================================== FAILURES ===================================
[ 20s] ____________________ TestCollectTypes.test_callee_star_args ____________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_callee_star_args>
[ 20s]
[ 20s] def test_callee_star_args(self):
[ 20s] # type: () -> None
[ 20s]
[ 20s] def callee_star_args(x, *y):
[ 20s] # type: (Any, *Any) -> Any
[ 20s] return 0
[ 20s]
[ 20s] with self.collecting_types():
[ 20s] callee_star_args(0)
[ 20s] callee_star_args(1, '')
[ 20s] callee_star_args(slice(1), 1.1, True)
[ 20s] callee_star_args(*(False, 1.1, ''))
[ 20s] > self.assert_type_comments('callee_star_args', ['(int) -> int',
[ 20s] '(int, *str) -> int',
[ 20s] '(slice, *Union[bool, float]) -> int',
[ 20s] '(bool, *Union[float, str]) -> int'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:484:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_callee_star_args>
[ 20s] func_name = 'callee_star_args'
[ 20s] comments = ['(int) -> int', '(int, *str) -> int', '(slice, *Union[bool, float]) -> int', '(bool, *Union[float, str]) -> int']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(bool, *Uni...NoReturnType'} == {'(bool, *Uni...oat]) -> int'}
[ 20s] E Extra items in the left set:
[ 20s] E '(bool, *Union[float, str]) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E '(int, *str) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E '(slice, *Union[bool, float]) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E '(int) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(int, *str) -> int'...
[ 20s] E
[ 20s] E ...Full output truncated (16 lines hidden), use '-vv' to show
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] (bool, *Union[float, str]) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (int) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (int, *str) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (slice, *Union[bool, float]) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] (bool, *Union[float, str]) -> int
[ 20s] (int) -> int
[ 20s] (int, *str) -> int
[ 20s] (slice, *Union[bool, float]) -> int
[ 20s] ____________________ TestCollectTypes.test_caller_star_args ____________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_caller_star_args>
[ 20s]
[ 20s] def test_caller_star_args(self):
[ 20s] # type: () -> None
[ 20s]
[ 20s] def caller_star_args(x, y=None):
[ 20s] # type: (Any, Any) -> Any
[ 20s] return 0
[ 20s]
[ 20s] with self.collecting_types():
[ 20s] caller_star_args(*(1,))
[ 20s] caller_star_args(*('', 1.1))
[ 20s] > self.assert_type_comments('caller_star_args', ['(int, None) -> int',
[ 20s] '(str, float) -> int'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:499:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_caller_star_args>
[ 20s] func_name = 'caller_star_args'
[ 20s] comments = ['(int, None) -> int', '(str, float) -> int']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(int, None)...NoReturnType'} == {'(int, None)...loat) -> int'}
[ 20s] E Extra items in the left set:
[ 20s] E '(int, None) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E '(str, float) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(int, None) -> int'
[ 20s] E '(str, float) -> int'
[ 20s] E Full diff:...
[ 20s] E
[ 20s] E ...Full output truncated (6 lines hidden), use '-vv' to show
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] (int, None) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (str, float) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] (int, None) -> int
[ 20s] (str, float) -> int
[ 20s] ___________________ TestCollectTypes.test_recursive_function ___________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_recursive_function>
[ 20s]
[ 20s] def test_recursive_function(self):
[ 20s] # type: () -> None
[ 20s]
[ 20s] def recurse(x):
[ 20s] # type: (Any) -> Any
[ 20s] if len(x) == 0:
[ 20s] return 1.1
[ 20s] else:
[ 20s] recurse(x[1:])
[ 20s] return x[0]
[ 20s]
[ 20s] with self.collecting_types():
[ 20s] recurse((1, '', True))
[ 20s] > self.assert_type_comments(
[ 20s] 'recurse',
[ 20s] ['(Tuple[]) -> float',
[ 20s] '(Tuple[bool]) -> pyannotate_runtime.collect_types.UnknownType',
[ 20s] '(Tuple[str, bool]) -> pyannotate_runtime.collect_types.UnknownType',
[ 20s] '(Tuple[int, str, bool]) -> pyannotate_runtime.collect_types.UnknownType'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:542:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_recursive_function>
[ 20s] func_name = 'recurse'
[ 20s] comments = ['(Tuple[]) -> float', '(Tuple[bool]) -> pyannotate_runtime.collect_types.UnknownType', '(Tuple[str, bool]) -> pyannotate_runtime.collect_types.UnknownType', '(Tuple[int, str, bool]) -> pyannotate_runtime.collect_types.UnknownType']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(Tuple[]) -....UnknownType'} == {'(Tuple[]) -....UnknownType'}
[ 20s] E Extra items in the left set:
[ 20s] E '(Tuple[]) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(Tuple[]) -> float'
[ 20s] E Full diff:
[ 20s] E {
[ 20s] E - '(Tuple[]) -> float',...
[ 20s] E
[ 20s] E ...Full output truncated (5 lines hidden), use '-vv' to show
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] (Tuple[]) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (Tuple[bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] (Tuple[int, str, bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] (Tuple[str, bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] Expected:
[ 20s] (Tuple[]) -> float
[ 20s] (Tuple[bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] (Tuple[int, str, bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] (Tuple[str, bool]) -> pyannotate_runtime.collect_types.UnknownType
[ 20s] __________________ TestCollectTypes.test_run_a_bunch_of_tests __________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_run_a_bunch_of_tests>
[ 20s]
[ 20s] def test_run_a_bunch_of_tests(self):
[ 20s] # type: () -> None
[ 20s] with self.collecting_types():
[ 20s] to = FooObject()
[ 20s] wc = WorkerClass(42, to)
[ 20s] s = sched.scheduler(time.time, time.sleep)
[ 20s] event_source = EventfulHappenings()
[ 20s] s.enter(.001, 1, wc.do_work, ([52, 'foo,', 32], FooNamedTuple('ab', 97)))
[ 20s] s.enter(.002, 1, wc.do_work, ([52, 32], FooNamedTuple('bc', 98)))
[ 20s] s.enter(.003, 1, wc.do_work_clsmthd, (52, FooNamedTuple('de', 99)))
[ 20s] s.enter(.004, 1, event_source.add_handler, (i_care_about_whats_happening,))
[ 20s] s.enter(.005, 1, event_source.add_handler, (lambda a, b: print_int(a),))
[ 20s] s.enter(.006, 1, event_source.something_happened, (1, 'tada'))
[ 20s] s.run()
[ 20s]
[ 20s] takes_different_lists([42, 'as', 323, 'a'])
[ 20s] takes_int_lists([42, 323, 3231])
[ 20s] takes_int_float_lists([42, 323.2132, 3231])
[ 20s] takes_int_to_str_dict({2: 'a', 4: 'd'})
[ 20s] takes_int_to_multiple_val_dict({3: 'a', 4: None, 5: 232})
[ 20s] recursive_dict({3: {3: 'd'}, 4: {3: 'd'}})
[ 20s]
[ 20s] empty_then_not_dict({})
[ 20s] empty_then_not_dict({3: {3: 'd'}, 4: {3: 'd'}})
[ 20s] empty_then_not_list([])
[ 20s] empty_then_not_list([1, 2])
[ 20s] empty_then_not_list([1, 2])
[ 20s] tuple_verify((1, '4'))
[ 20s] tuple_verify((1, '4'))
[ 20s]
[ 20s] problematic_dup(u'ha', False)
[ 20s] problematic_dup(u'ha', False)
[ 20s]
[ 20s] OldStyleClass().foo(10)
[ 20s]
[ 20s] discard(FooObject.FooNested())
[ 20s]
[ 20s] # TODO(svorobev): add checks for the rest of the functions
[ 20s] # print_int,
[ 20s] > self.assert_type_comments(
[ 20s] 'WorkerClass.__init__',
[ 20s] ['(int, pyannotate_runtime.tests.test_collect_types.FooObject) -> None'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:326:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_run_a_bunch_of_tests>
[ 20s] func_name = 'WorkerClass.__init__'
[ 20s] comments = ['(int, pyannotate_runtime.tests.test_collect_types.FooObject) -> None']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(int, pyann...NoReturnType'} == {'(int, pyann...ect) -> None'}
[ 20s] E Extra items in the left set:
[ 20s] E '(int, pyannotate_runtime.tests.test_collect_types.FooObject) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(int, pyannotate_runtime.tests.test_collect_types.FooObject) -> None'
[ 20s] E Full diff:
[ 20s] E {
[ 20s] E - '(int, pyannotate_runtime.tests.test_collect_types.FooObject) -> None',...
[ 20s] E
[ 20s] E ...Full output truncated (4 lines hidden), use '-vv' to show
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] [52, 'foo,', 32]
[ 20s] [52, 32]
[ 20s] 52
[ 20s] 1
[ 20s] tada
[ 20s] 1
[ 20s] Actual:
[ 20s] (int, pyannotate_runtime.tests.test_collect_types.FooObject) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] (int, pyannotate_runtime.tests.test_collect_types.FooObject) -> None
[ 20s] _____________________ TestCollectTypes.test_star_star_args _____________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_star_star_args>
[ 20s]
[ 20s] def test_star_star_args(self):
[ 20s] # type: () -> None
[ 20s]
[ 20s] def star_star_args(x, **kw):
[ 20s] # type: (Any, **Any) -> Any
[ 20s] return 0
[ 20s]
[ 20s] with self.collecting_types():
[ 20s] star_star_args(1, y='', z=True)
[ 20s] star_star_args(**{'x': True, 'a': 1.1})
[ 20s] > self.assert_type_comments('star_star_args', ['(int) -> int',
[ 20s] '(bool) -> int'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:512:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_star_star_args>
[ 20s] func_name = 'star_star_args', comments = ['(int) -> int', '(bool) -> int']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(bool) -> p...NoReturnType'} == {'(bool) -> i...(int) -> int'}
[ 20s] E Extra items in the left set:
[ 20s] E '(int) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E '(bool) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(bool) -> int'
[ 20s] E '(int) -> int'
[ 20s] E Full diff:...
[ 20s] E
[ 20s] E ...Full output truncated (6 lines hidden), use '-vv' to show
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] (bool) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] (int) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] (bool) -> int
[ 20s] (int) -> int
[ 20s] _____________ TestCollectTypes.test_type_collection_on_main_thread _____________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_type_collection_on_main_thread>
[ 20s]
[ 20s] def test_type_collection_on_main_thread(self):
[ 20s] # type: () -> None
[ 20s] with self.collecting_types():
[ 20s] self.foo(2, ['1', '2'])
[ 20s] > self.assert_type_comments('TestCollectTypes.foo', ['(int, List[str]) -> None'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:264:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_type_collection_on_main_thread>
[ 20s] func_name = 'TestCollectTypes.foo', comments = ['(int, List[str]) -> None']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'(int, List[...NoReturnType'} == {'(int, List[str]) -> None'}
[ 20s] E Extra items in the left set:
[ 20s] E '(int, List[str]) -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '(int, List[str]) -> None'
[ 20s] E Full diff:
[ 20s] E - {'(int, List[str]) -> None'}
[ 20s] E + {'(int, List[str]) -> pyannotate_runtime.collect_types.NoReturnType'}
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] (int, List[str]) -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] (int, List[str]) -> None
[ 20s] ______________________ TestCollectTypes.test_yield_empty _______________________
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_yield_empty>
[ 20s]
[ 20s] def test_yield_empty(self):
[ 20s] # type: () -> None
[ 20s] def gen():
[ 20s] if False:
[ 20s] yield
[ 20s]
[ 20s] with self.collecting_types():
[ 20s] list(gen())
[ 20s]
[ 20s] > self.assert_type_comments('gen', ['() -> Iterator'])
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:655:
[ 20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 20s]
[ 20s] self = <pyannotate_runtime.tests.test_collect_types.TestCollectTypes testMethod=test_yield_empty>
[ 20s] func_name = 'gen', comments = ['() -> Iterator']
[ 20s]
[ 20s] def assert_type_comments(self, func_name, comments):
[ 20s] # type: (str, List[str]) -> None
[ 20s] """Assert that we generated expected comment for the func_name function in self.stats"""
[ 20s] stat_items = [item for item in self.stats if item.get('func_name') == func_name]
[ 20s] if not comments and not stat_items:
[ 20s] # If we expect no comments, it's okay if nothing was collected.
[ 20s] return
[ 20s] assert len(stat_items) == 1
[ 20s] item = stat_items[0]
[ 20s] if set(item['type_comments']) != set(comments):
[ 20s] print('Actual:')
[ 20s] for comment in sorted(item['type_comments']):
[ 20s] print(' ' + comment)
[ 20s] print('Expected:')
[ 20s] for comment in sorted(comments):
[ 20s] print(' ' + comment)
[ 20s] > assert set(item['type_comments']) == set(comments)
[ 20s] E AssertionError: assert {'() -> pyann...NoReturnType'} == {'() -> Iterator'}
[ 20s] E Extra items in the left set:
[ 20s] E '() -> pyannotate_runtime.collect_types.NoReturnType'
[ 20s] E Extra items in the right set:
[ 20s] E '() -> Iterator'
[ 20s] E Full diff:
[ 20s] E - {'() -> Iterator'}
[ 20s] E + {'() -> pyannotate_runtime.collect_types.NoReturnType'}
[ 20s]
[ 20s] pyannotate_runtime/tests/test_collect_types.py:230: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] Actual:
[ 20s] () -> pyannotate_runtime.collect_types.NoReturnType
[ 20s] Expected:
[ 20s] () -> Iterator
[ 20s] _________________________ IntegrationTest.test_package _________________________
[ 20s]
[ 20s] self = <integration_test.IntegrationTest testMethod=test_package>
[ 20s]
[ 20s] def test_package(self):
[ 20s] os.makedirs('foo')
[ 20s] with open('foo/__init__.py', 'w') as f:
[ 20s] pass
[ 20s] with open('foo/gcd.py', 'w') as f:
[ 20s] f.write(example)
[ 20s] with open('driver.py', 'w') as f:
[ 20s] f.write('from foo.gcd import main\n')
[ 20s] f.write(driver)
[ 20s] subprocess.check_call([sys.executable, 'driver.py'])
[ 20s] output = subprocess.check_output([sys.executable, '-m', 'pyannotate_tools.annotations', 'foo/gcd.py'])
[ 20s] lines = output.splitlines()
[ 20s] > assert b'+ # type: () -> None' in lines
[ 20s] E AssertionError: assert b'+ # type: () -> None' in [b'--- foo/gcd.py\t(original)', b'+++ foo/gcd.py\t(refactored)', b'@@ -1,9 +1,12 @@', b'+from mypy_extensions import NoReturn', b' ', b' def main():', ...]
[ 20s]
[ 20s] tests/integration_test.py:101: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] 5
[ 20s] 3
[ 20s] ----------------------------- Captured stderr call -----------------------------
[ 20s] /home/abuild/rpmbuild/BUILD/pyannotate-1.2.0/pyannotate_tools/annotations/__main__.py:9: DeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
[ 20s] from lib2to3.main import StdoutRefactoringTool
[ 20s] Refactored foo/gcd.py
[ 20s] Files that need to be modified:
[ 20s] foo/gcd.py
[ 20s] NOTE: this was a dry run; use -w to write files
[ 20s] _________________________ IntegrationTest.test_simple __________________________
[ 20s]
[ 20s] self = <integration_test.IntegrationTest testMethod=test_simple>
[ 20s]
[ 20s] def test_simple(self):
[ 20s] with open('gcd.py', 'w') as f:
[ 20s] f.write(example)
[ 20s] with open('driver.py', 'w') as f:
[ 20s] f.write('from gcd import main\n')
[ 20s] f.write(driver)
[ 20s] subprocess.check_call([sys.executable, 'driver.py'])
[ 20s] output = subprocess.check_output([sys.executable, '-m', 'pyannotate_tools.annotations', 'gcd.py'])
[ 20s] lines = output.splitlines()
[ 20s] > assert b'+ # type: () -> None' in lines
[ 20s] E AssertionError: assert b'+ # type: () -> None' in [b'--- gcd.py\t(original)', b'+++ gcd.py\t(refactored)', b'@@ -1,9 +1,12 @@', b'+from mypy_extensions import NoReturn', b' ', b' def main():', ...]
[ 20s]
[ 20s] tests/integration_test.py:65: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] 5
[ 20s] 3
[ 20s] ----------------------------- Captured stderr call -----------------------------
[ 20s] /home/abuild/rpmbuild/BUILD/pyannotate-1.2.0/pyannotate_tools/annotations/__main__.py:9: DeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
[ 20s] from lib2to3.main import StdoutRefactoringTool
[ 20s] Refactored gcd.py
[ 20s] Files that need to be modified:
[ 20s] gcd.py
[ 20s] NOTE: this was a dry run; use -w to write files
[ 20s] _________________________ IntegrationTest.test_subdir __________________________
[ 20s]
[ 20s] self = <integration_test.IntegrationTest testMethod=test_subdir>
[ 20s]
[ 20s] def test_subdir(self):
[ 20s] os.makedirs('foo')
[ 20s] with open('foo/gcd.py', 'w') as f:
[ 20s] f.write(example)
[ 20s] with open('driver.py', 'w') as f:
[ 20s] f.write('import sys\n')
[ 20s] f.write('sys.path.insert(0, "foo")\n')
[ 20s] f.write('from gcd import main\n')
[ 20s] f.write(driver)
[ 20s] subprocess.check_call([sys.executable, 'driver.py'])
[ 20s] output = subprocess.check_output([sys.executable, '-m', 'pyannotate_tools.annotations',
[ 20s] # Construct platform-correct pathname:
[ 20s] os.path.join('foo', 'gcd.py')])
[ 20s] lines = output.splitlines()
[ 20s] > assert b'+ # type: () -> None' in lines
[ 20s] E AssertionError: assert b'+ # type: () -> None' in [b'--- foo/gcd.py\t(original)', b'+++ foo/gcd.py\t(refactored)', b'@@ -1,9 +1,12 @@', b'+from mypy_extensions import NoReturn', b' ', b' def main():', ...]
[ 20s]
[ 20s] tests/integration_test.py:118: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] 5
[ 20s] 3
[ 20s] ----------------------------- Captured stderr call -----------------------------
[ 20s] /home/abuild/rpmbuild/BUILD/pyannotate-1.2.0/pyannotate_tools/annotations/__main__.py:9: DeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
[ 20s] from lib2to3.main import StdoutRefactoringTool
[ 20s] Refactored foo/gcd.py
[ 20s] Files that need to be modified:
[ 20s] foo/gcd.py
[ 20s] NOTE: this was a dry run; use -w to write files
[ 20s] _____________________ IntegrationTest.test_subdir_w_class ______________________
[ 20s]
[ 20s] self = <integration_test.IntegrationTest testMethod=test_subdir_w_class>
[ 20s]
[ 20s] def test_subdir_w_class(self):
[ 20s] os.makedirs('foo')
[ 20s] with open('foo/bar.py', 'w') as f:
[ 20s] f.write(class_example)
[ 20s] with open('driver.py', 'w') as f:
[ 20s] f.write('import sys\n')
[ 20s] f.write('sys.path.insert(0, "foo")\n')
[ 20s] f.write('from bar import main\n')
[ 20s] f.write(driver)
[ 20s] subprocess.check_call([sys.executable, 'driver.py'])
[ 20s] output = subprocess.check_output([sys.executable, '-m', 'pyannotate_tools.annotations',
[ 20s] # Construct platform-correct pathname:
[ 20s] os.path.join('foo', 'bar.py')])
[ 20s] lines = output.splitlines()
[ 20s] print(b'\n'.join(lines).decode())
[ 20s] > assert b'+ # type: () -> None' in lines
[ 20s] E AssertionError: assert b'+ # type: () -> None' in [b'--- foo/bar.py\t(original)', b'+++ foo/bar.py\t(refactored)', b'@@ -1,9 +1,12 @@', b'+from mypy_extensions import NoReturn', b' ', b' class A(object): pass', ...]
[ 20s]
[ 20s] tests/integration_test.py:136: AssertionError
[ 20s] ----------------------------- Captured stdout call -----------------------------
[ 20s] --- foo/bar.py (original)
[ 20s] +++ foo/bar.py (refactored)
[ 20s] @@ -1,9 +1,12 @@
[ 20s] +from mypy_extensions import NoReturn
[ 20s]
[ 20s] class A(object): pass
[ 20s]
[ 20s] def f(x):
[ 20s] + # type: (A) -> A
[ 20s] return x
[ 20s]
[ 20s] def main():
[ 20s] + # type: () -> NoReturn
[ 20s] f(A())
[ 20s] f(A())
[ 20s] ----------------------------- Captured stderr call -----------------------------
Metadata
Metadata
Assignees
Labels
No labels