11import re
2+ import sys
23import unittest
34
45from getgauge .registry import Registry
@@ -160,9 +161,12 @@ def test_Registry_before_spec_with_tags(self):
160161 registry .add_before_spec (info ['func' ], info ['tags' ])
161162
162163 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .before_spec ([])])
163- self .assertEqual ([x ['func' ] for x in infos ], [i .impl for i in registry .before_spec (['A' , 'b' ])])
164- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .before_spec (['A' , 'b' , 'c' ])])
165- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .before_spec (['A' ])])
164+ self .assertEqual ([x ['func' ] for x in infos ], [
165+ i .impl for i in registry .before_spec (['A' , 'b' ])])
166+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
167+ i .impl for i in registry .before_spec (['A' , 'b' , 'c' ])])
168+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
169+ i .impl for i in registry .before_spec (['A' ])])
166170 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .before_spec (['A' , 'c' ])])
167171
168172 def test_Registry_after_spec_with_tags (self ):
@@ -176,9 +180,12 @@ def test_Registry_after_spec_with_tags(self):
176180 registry .add_after_spec (info ['func' ], info ['tags' ])
177181
178182 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .after_spec ([])])
179- self .assertEqual ([x ['func' ] for x in infos ], [i .impl for i in registry .after_spec (['A' , 'b' ])])
180- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .after_spec (['A' , 'b' , 'c' ])])
181- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .after_spec (['A' ])])
183+ self .assertEqual ([x ['func' ] for x in infos ], [
184+ i .impl for i in registry .after_spec (['A' , 'b' ])])
185+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
186+ i .impl for i in registry .after_spec (['A' , 'b' , 'c' ])])
187+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
188+ i .impl for i in registry .after_spec (['A' ])])
182189 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .after_spec (['A' , 'c' ])])
183190
184191 def test_Registry_before_scenario (self ):
@@ -269,9 +276,12 @@ def test_Registry_before_step_with_tags(self):
269276 registry .add_before_step (info ['func' ], info ['tags' ])
270277
271278 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .before_step ([])])
272- self .assertEqual ([x ['func' ] for x in infos ], [i .impl for i in registry .before_step (['A' , 'b' ])])
273- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .before_step (['A' , 'b' , 'c' ])])
274- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .before_step (['A' ])])
279+ self .assertEqual ([x ['func' ] for x in infos ], [
280+ i .impl for i in registry .before_step (['A' , 'b' ])])
281+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
282+ i .impl for i in registry .before_step (['A' , 'b' , 'c' ])])
283+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
284+ i .impl for i in registry .before_step (['A' ])])
275285 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .before_step (['A' , 'c' ])])
276286
277287 def test_Registry_after_step_with_tags (self ):
@@ -286,9 +296,12 @@ def test_Registry_after_step_with_tags(self):
286296 registry .add_after_step (info ['func' ], info ['tags' ])
287297
288298 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .after_step ([])])
289- self .assertEqual ([x ['func' ] for x in infos ], [i .impl for i in registry .after_step (['A' , 'b' ])])
290- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .after_step (['A' , 'b' , 'c' ])])
291- self .assertEqual ([info1 ['func' ], info3 ['func' ]], [i .impl for i in registry .after_step (['A' ])])
299+ self .assertEqual ([x ['func' ] for x in infos ], [
300+ i .impl for i in registry .after_step (['A' , 'b' ])])
301+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
302+ i .impl for i in registry .after_step (['A' , 'b' , 'c' ])])
303+ self .assertEqual ([info1 ['func' ], info3 ['func' ]], [
304+ i .impl for i in registry .after_step (['A' ])])
292305 self .assertEqual ([info1 ['func' ]], [i .impl for i in registry .after_step (['A' , 'c' ])])
293306
294307 def test_Registry__step_positions_of_a_given_file (self ):
@@ -361,6 +374,7 @@ def test_Registry_get_all_methods_in_should_give_all_the_methods_define_in_that_
361374 self .assertEqual (3 , len (registry .get_all_methods_in ("foo.py" )))
362375 self .assertEqual (2 , len (registry .get_all_methods_in ("bar.py" )))
363376
377+ @unittest .skipIf (sys .platform == "darwin" , "Fails on macOS due to case sensitivity" )
364378 def test_Registry_get_all_methods_in_should_handle_paths_case_sensitive (self ):
365379 lower_c_drive = 'c:/random/path/foo.py'
366380 upper_c_drive = 'C:/random/path/foo.py'
@@ -376,6 +390,22 @@ def test_Registry_get_all_methods_in_should_handle_paths_case_sensitive(self):
376390 self .assertEqual (2 , len (registry .get_all_methods_in (lower_c_drive )))
377391 self .assertEqual (2 , len (registry .get_all_methods_in (upper_c_drive )))
378392
393+ @unittest .skipIf (sys .platform .startswith ("win" ), "Fails on macOS due to case sensitivity" )
394+ def test_Registry_get_all_methods_in_should_handle_paths_case_sensitive_on_mac (self ):
395+ path1 = '/random/path/foo.py'
396+ path2 = '/random/PATH/foo.py'
397+
398+ step_infos = [
399+ {'text' : 'Foo' , 'func' : 'func1' , 'file_name' : path1 },
400+ {'text' : 'Foo <>' , 'func' : 'func2' , 'file_name' : path2 }
401+ ]
402+ for info in step_infos :
403+ registry .add_step (info ['text' ], info ['func' ], info ['file_name' ])
404+
405+ """ Note: since the paths are in fact different, they should be treated as different paths! """
406+ self .assertEqual (1 , len (registry .get_all_methods_in (path1 )))
407+ self .assertEqual (1 , len (registry .get_all_methods_in (path2 )))
408+
379409 def tearDown (self ):
380410 global registry
381411 registry = Registry ()
0 commit comments