@@ -56,55 +56,29 @@ def test__get_validator_from_module__pdf_file__raises(self, tmp_path):
5656 with pytest .raises (CustomTestFunctionLoaderError , match = "Could not load" ):
5757 _get_validator_from_module (SAMPLE_PDF_PATH )
5858
59- def test__get_validator_from_regex (self ):
59+ def test__get_validator_from_regex__should_pass (self ):
6060 validator = _get_validator_from_regex ("test_garbage.*" )
6161 assert validator ("test_garbage_test123" ) is True
62+ assert validator ("test_no_match" ) is False
6263
63- def test__resolve_path_absolute (self ):
64+ def test__resolve_path_absolute__should_pass (self ):
6465 assert resolve_path ("/tmp" ) == "/tmp"
6566
66- def test__resolve_path_relative (self ):
67+ def test__resolve_path_relative__should_pass (self ):
6768 assert resolve_path ("./tmp" ) == os .path .abspath ("./tmp" )
6869
69- def test__resolve_path_expand (self ):
70+ def test__resolve_path_expand__should_pass (self ):
7071 assert resolve_path ("~/tmp" ) == os .path .expanduser ("~/tmp" )
7172
72- #
73- # @pytest.mark.parametrize(
74- # "func_name",
75- # [
76- # "test_method__when__then",
77- # "test__protectedmethod__when__then",
78- # "test___privatemethod__when__then",
79- # "test_method__when_blabla__then_blabla",
80- # "test__method__when_blabla__then_blabla",
81- # ],
82- # )
83- # def test_check_test_func_name__valid_test_name__return_true(self, func_name):
84- # assert check_test_func_name(func_name) is True
85- #
86- # @pytest.mark.parametrize(
87- # "func_name",
88- # [
89- # "garbage",
90- # "garbage_method",
91- # "test_myfunc_shouldpass",
92- # "test__myfunc__shouldpass_when_this",
93- # "test___myfunc__shouldpass_when_that__",
94- # ],
95- # )
96- # def test_check_test_func_name__invalid_test_name__return_false(self, func_name):
97- # assert check_test_func_name(func_name) is False
98-
9973
10074class TestFlake8Optparse :
101- def test__add_options (self ):
75+ def test__add_options__should_pass (self ):
10276 flake8_opt_mgr = OptionManager (prog = "flake8" , version = flake8 .__version__ ,)
10377 plugin = Flake8Argparse (None , SAMPLE_FILE_PATH )
10478 plugin .add_options (flake8_opt_mgr )
10579 assert len (flake8_opt_mgr .options ) == 2
10680
107- def test__parse_options (self ):
81+ def test__parse_options__should_pass (self ):
10882 flake8_opt_mgr = OptionManager (prog = "flake8" , version = flake8 .__version__ )
10983 plugin = Flake8Argparse (None , SAMPLE_FILE_PATH )
11084 args = SysArgs (
@@ -122,7 +96,7 @@ def test__parse_options(self):
12296
12397
12498class TestMyVisitor :
125- def test_visitor_find_all_methods (self ):
99+ def test_visit__simple_module__find_all_methods (self ):
126100 code_snippet = (
127101 "import garbage\n \n def test_method():\n pass\n \n def foo():\n pass"
128102 )
@@ -137,11 +111,11 @@ def test_visitor_find_all_methods(self):
137111
138112
139113class TestMyFlake8Plugin :
140- def test__format_code (self ):
114+ def test_format_code__should_pass (self ):
141115 checker = MyFlake8Plugin (None , SAMPLE_FILE_PATH )
142116 assert checker .format_code (302 ) == "TN302"
143117
144- def test__get_invalid_test_methods__no_match (self ):
118+ def test_get_invalid_test_methods__simple_case__no_invalid_match (self ):
145119 code_snippet = "import garbage\n \n def test__im_a_valid_method__when_this__then_that():\n pass"
146120 tree = get_tree_from_str (code_snippet )
147121
@@ -151,7 +125,7 @@ def validator(func_name):
151125 invalid_methods = list (MyFlake8Plugin .get_invalid_test_methods (tree , validator ))
152126 assert not invalid_methods
153127
154- def test__get_invalid_test_methods__match (self ):
128+ def test_get_invalid_test_methods__simple_case__finds_invalid_match (self ):
155129 code_snippet = "import garbage\n \n def test_im_an_valid_method():\n pass"
156130 tree = get_tree_from_str (code_snippet )
157131
@@ -161,7 +135,7 @@ def validator(func_name):
161135 invalid_methods = list (MyFlake8Plugin .get_invalid_test_methods (tree , validator ))
162136 assert invalid_methods
163137
164- def test_run__using_regex__no_match (self ):
138+ def test_run__using_regex_on_sample_file__no_invalid_match (self ):
165139 tree = get_tree (SAMPLE_FILE_PATH )
166140 args = SysArgs (
167141 test_func_name_validator_regex = "test_.*" ,
@@ -175,7 +149,7 @@ def test_run__using_regex__no_match(self):
175149 res = list (checker .run ())
176150 assert res == expected
177151
178- def test_run__using_regex__match (self ):
152+ def test_run__using_regex_on_sample_file__finds_invalid_match (self ):
179153 tree = get_tree (SAMPLE_FILE_PATH )
180154 args = SysArgs (
181155 test_func_name_validator_regex = "test_funkyconvention.*" ,
@@ -214,7 +188,7 @@ def test_run__using_regex__match(self):
214188 res = list (checker .run ())
215189 assert res == expected
216190
217- def test_run__using_regex__no_invalid_test (self ):
191+ def test_run__using_regex__no_invalid_match (self ):
218192 code_snippet = "import garbage\n \n def foo():\n pass\n \n def bar():\n pass"
219193 tree = get_tree_from_str (code_snippet )
220194 args = SysArgs (
@@ -229,7 +203,7 @@ def test_run__using_regex__no_invalid_test(self):
229203 res = list (checker .run ())
230204 assert res == expected
231205
232- def test_run__using_module__match (self ):
206+ def test_run__using_module__finds_invalid_match (self ):
233207 tree = get_tree (SAMPLE_FILE_PATH )
234208 args = SysArgs (
235209 test_func_name_validator_module = SAMPLE_VALIDATOR_MODULE_PATH ,
@@ -291,13 +265,15 @@ def test_run__file_not_in_test_dir__simply_skipped(self):
291265 res = list (checker .run ())
292266 assert res == expected
293267
294- checker = MyFlake8Plugin (tree , "/tmp/regular_dir/test.py" )
268+ # Simulate a non-test-file with test functions
269+ # and confirm that it is simply skipped
270+ checker = MyFlake8Plugin (tree , "/tmp/regular_dir/garbage.py" )
295271 checker .parse_options (None , args , None )
296272
297273 res = list (checker .run ())
298274 assert not res
299275
300- def test_run__no_validator__raises (self ):
276+ def test_run__no_validator_provided__raises (self ):
301277 tree = get_tree (SAMPLE_FILE_PATH )
302278 checker = MyFlake8Plugin (tree , SAMPLE_FILE_PATH )
303279 checker .parse_options (None , SysArgs (None , None ), None )
0 commit comments