File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -321,3 +321,28 @@ def test_discover_package_path_no_source_root_overlap(tmp_path):
321
321
322
322
expected = source_roots
323
323
assert package_paths == expected
324
+
325
+ def test_discover_package_path_legacy ():
326
+ """Test for legacy path discovery when source_roots is empty
327
+ """
328
+ source_roots = []
329
+ package_paths = discover_package_path (__file__ , source_roots )
330
+
331
+ # First ancestor directory without __init__.py
332
+ expected = [str (Path (__file__ ).parent .parent .absolute ())]
333
+
334
+ assert package_paths == expected
335
+
336
+ def test_discover_package_path_legacy_no_parent_without_init_py (tmp_path , monkeypatch ):
337
+ """Test to return current directory if no parent directory without
338
+ __init__.py is found"""
339
+ source_roots = []
340
+
341
+ monkeypatch .setattr (os .path , "exists" , lambda path : True )
342
+ monkeypatch .setattr (os .path , "dirname" , lambda path : path )
343
+
344
+ package_paths = discover_package_path (tmp_path , source_roots )
345
+
346
+ expected = [os .getcwd ()]
347
+
348
+ assert package_paths == expected
You can’t perform that action at this time.
0 commit comments