11# Copyright (c) 2008-2012 testtools developers. See LICENSE for details.
22
33import re
4- from typing import ClassVar
4+ from typing import Any , ClassVar
55
66from testtools import TestCase
77from testtools .compat import text_repr
2424 _BinaryMismatch ,
2525 _NotNearlyEqual ,
2626)
27+ from testtools .matchers ._impl import Matcher
2728from testtools .matchers .test import TestMatchersInterface
2829
2930from ..helpers import FullStackRunTest
@@ -114,9 +115,9 @@ def test_long_unicode_and_object(self):
114115
115116
116117class TestEqualsInterface (TestCase , TestMatchersInterface ):
117- matches_matcher : ClassVar = Equals (1 )
118- matches_matches : ClassVar = [1 ]
119- matches_mismatches : ClassVar = [2 ]
118+ matches_matcher : ClassVar [ Matcher [ Any ]] = Equals (1 )
119+ matches_matches : ClassVar [ list [ Any ]] = [1 ]
120+ matches_mismatches : ClassVar [ list [ Any ]] = [2 ]
120121
121122 str_examples : ClassVar = [
122123 ("Equals(1)" , Equals (1 )),
@@ -138,9 +139,9 @@ class TestEqualsInterface(TestCase, TestMatchersInterface):
138139
139140
140141class TestNotEqualsInterface (TestCase , TestMatchersInterface ):
141- matches_matcher : ClassVar = NotEquals (1 )
142- matches_matches : ClassVar = [2 ]
143- matches_mismatches : ClassVar = [1 ]
142+ matches_matcher : ClassVar [ Matcher [ Any ]] = NotEquals (1 )
143+ matches_matches : ClassVar [ list [ Any ]] = [2 ]
144+ matches_mismatches : ClassVar [ list [ Any ]] = [1 ]
144145
145146 str_examples : ClassVar = [
146147 ("NotEquals(1)" , NotEquals (1 )),
@@ -154,9 +155,9 @@ class TestIsInterface(TestCase, TestMatchersInterface):
154155 foo = object ()
155156 bar = object ()
156157
157- matches_matcher : ClassVar = Is (foo )
158- matches_matches : ClassVar = [foo ]
159- matches_mismatches : ClassVar = [bar , 1 ]
158+ matches_matcher : ClassVar [ Matcher [ Any ]] = Is (foo )
159+ matches_matches : ClassVar [ list [ Any ]] = [foo ]
160+ matches_mismatches : ClassVar [ list [ Any ]] = [bar , 1 ]
160161
161162 str_examples : ClassVar = [("Is(2)" , Is (2 ))]
162163
@@ -167,9 +168,9 @@ class TestIsInstanceInterface(TestCase, TestMatchersInterface):
167168 class Foo :
168169 pass
169170
170- matches_matcher : ClassVar = IsInstance (Foo )
171- matches_matches : ClassVar = [Foo ()]
172- matches_mismatches : ClassVar = [object (), 1 , Foo ]
171+ matches_matcher : ClassVar [ Matcher [ Any ]] = IsInstance (Foo )
172+ matches_matches : ClassVar [ list [ Any ]] = [Foo ()]
173+ matches_mismatches : ClassVar [ list [ Any ]] = [object (), 1 , Foo ]
173174
174175 str_examples : ClassVar = [
175176 ("IsInstance(str)" , IsInstance (str )),
@@ -187,9 +188,9 @@ class Foo:
187188
188189
189190class TestLessThanInterface (TestCase , TestMatchersInterface ):
190- matches_matcher : ClassVar = LessThan (4 )
191- matches_matches : ClassVar = [- 5 , 3 ]
192- matches_mismatches : ClassVar = [4 , 5 , 5000 ]
191+ matches_matcher : ClassVar [ Matcher [ Any ]] = LessThan (4 )
192+ matches_matches : ClassVar [ list [ Any ]] = [- 5 , 3 ]
193+ matches_mismatches : ClassVar [ list [ Any ]] = [4 , 5 , 5000 ]
193194
194195 str_examples : ClassVar = [
195196 ("LessThan(12)" , LessThan (12 )),
@@ -202,9 +203,9 @@ class TestLessThanInterface(TestCase, TestMatchersInterface):
202203
203204
204205class TestGreaterThanInterface (TestCase , TestMatchersInterface ):
205- matches_matcher : ClassVar = GreaterThan (4 )
206- matches_matches : ClassVar = [5 , 8 ]
207- matches_mismatches : ClassVar = [- 2 , 0 , 4 ]
206+ matches_matcher : ClassVar [ Matcher [ Any ]] = GreaterThan (4 )
207+ matches_matches : ClassVar [ list [ Any ]] = [5 , 8 ]
208+ matches_mismatches : ClassVar [ list [ Any ]] = [- 2 , 0 , 4 ]
208209
209210 str_examples : ClassVar = [
210211 ("GreaterThan(12)" , GreaterThan (12 )),
@@ -217,9 +218,9 @@ class TestGreaterThanInterface(TestCase, TestMatchersInterface):
217218
218219
219220class TestContainsInterface (TestCase , TestMatchersInterface ):
220- matches_matcher : ClassVar = Contains ("foo" )
221- matches_matches : ClassVar = ["foo" , "afoo" , "fooa" ]
222- matches_mismatches : ClassVar = ["f" , "fo" , "oo" , "faoo" , "foao" ]
221+ matches_matcher : ClassVar [ Matcher [ Any ]] = Contains ("foo" )
222+ matches_matches : ClassVar [ list [ Any ]] = ["foo" , "afoo" , "fooa" ]
223+ matches_mismatches : ClassVar [ list [ Any ]] = ["f" , "fo" , "oo" , "faoo" , "foao" ]
223224
224225 str_examples : ClassVar = [
225226 ("Contains(1)" , Contains (1 )),
@@ -352,14 +353,14 @@ def test_mismatch_sets_expected(self):
352353
353354
354355class TestSameMembers (TestCase , TestMatchersInterface ):
355- matches_matcher : ClassVar = SameMembers ([1 , 1 , 2 , 3 , {"foo" : "bar" }])
356- matches_matches : ClassVar = [
356+ matches_matcher : ClassVar [ Matcher [ Any ]] = SameMembers ([1 , 1 , 2 , 3 , {"foo" : "bar" }])
357+ matches_matches : ClassVar [ list [ Any ]] = [
357358 [1 , 1 , 2 , 3 , {"foo" : "bar" }],
358359 [3 , {"foo" : "bar" }, 1 , 2 , 1 ],
359360 [3 , 2 , 1 , {"foo" : "bar" }, 1 ],
360361 (2 , {"foo" : "bar" }, 3 , 1 , 1 ),
361362 ]
362- matches_mismatches : ClassVar = [
363+ matches_mismatches : ClassVar [ list [ Any ]] = [
363364 {1 , 2 , 3 },
364365 [1 , 1 , 2 , 3 , 5 ],
365366 [1 , 2 , 3 , {"foo" : "bar" }],
@@ -405,9 +406,9 @@ class TestSameMembers(TestCase, TestMatchersInterface):
405406
406407
407408class TestMatchesRegex (TestCase , TestMatchersInterface ):
408- matches_matcher : ClassVar = MatchesRegex ("a|b" )
409- matches_matches : ClassVar = ["a" , "b" ]
410- matches_mismatches : ClassVar = ["c" ]
409+ matches_matcher : ClassVar [ Matcher [ Any ]] = MatchesRegex ("a|b" )
410+ matches_matches : ClassVar [ list [ Any ]] = ["a" , "b" ]
411+ matches_mismatches : ClassVar [ list [ Any ]] = ["c" ]
411412
412413 str_examples : ClassVar = [
413414 ("MatchesRegex('a|b')" , MatchesRegex ("a|b" )),
@@ -430,9 +431,9 @@ class TestMatchesRegex(TestCase, TestMatchersInterface):
430431
431432
432433class TestHasLength (TestCase , TestMatchersInterface ):
433- matches_matcher : ClassVar = HasLength (2 )
434- matches_matches : ClassVar = [[1 , 2 ]]
435- matches_mismatches : ClassVar = [[], [1 ], [3 , 2 , 1 ]]
434+ matches_matcher : ClassVar [ Matcher [ Any ]] = HasLength (2 )
435+ matches_matches : ClassVar [ list [ Any ]] = [[1 , 2 ]]
436+ matches_mismatches : ClassVar [ list [ Any ]] = [[], [1 ], [3 , 2 , 1 ]]
436437
437438 str_examples : ClassVar = [
438439 ("HasLength(2)" , HasLength (2 )),
@@ -444,9 +445,9 @@ class TestHasLength(TestCase, TestMatchersInterface):
444445
445446
446447class TestNearlyInterface (TestCase , TestMatchersInterface ):
447- matches_matcher : ClassVar = Nearly (4.0 , delta = 0.5 )
448- matches_matches : ClassVar = [4.0 , 4.5 , 3.5 , 4.25 , 3.75 ]
449- matches_mismatches : ClassVar = [4.51 , 3.49 , 5.0 , 2.0 , "not a number" ]
448+ matches_matcher : ClassVar [ Matcher [ Any ]] = Nearly (4.0 , delta = 0.5 )
449+ matches_matches : ClassVar [ list [ Any ]] = [4.0 , 4.5 , 3.5 , 4.25 , 3.75 ]
450+ matches_mismatches : ClassVar [ list [ Any ]] = [4.51 , 3.49 , 5.0 , 2.0 , "not a number" ]
450451
451452 str_examples : ClassVar = [
452453 ("Nearly(4.0, delta=0.5)" , Nearly (4.0 , delta = 0.5 )),
0 commit comments