Skip to content

Commit

Permalink
When the cwd is / then consider the search path as ""
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed Mar 13, 2024
1 parent ced0a18 commit 786adbc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Lib/test/test_importlib/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ def test_spec_from_loader_is_package_true_with_fileloader(self):
self.assertEqual(spec.loader, self.fileloader)
self.assertEqual(spec.origin, self.path)
self.assertIs(spec.loader_state, None)
self.assertEqual(spec.submodule_search_locations, [os.getcwd()])
location = cwd if (cwd := os.getcwd()) != '/' else ''
self.assertEqual(spec.submodule_search_locations, [location])
self.assertEqual(spec.cached, self.cached)
self.assertTrue(spec.has_location)

Expand Down Expand Up @@ -601,7 +602,8 @@ def test_spec_from_file_location_smsl_empty(self):
self.assertEqual(spec.loader, self.fileloader)
self.assertEqual(spec.origin, self.path)
self.assertIs(spec.loader_state, None)
self.assertEqual(spec.submodule_search_locations, [os.getcwd()])
location = cwd if (cwd := os.getcwd()) != '/' else ''
self.assertEqual(spec.submodule_search_locations, [location])
self.assertEqual(spec.cached, self.cached)
self.assertTrue(spec.has_location)

Expand All @@ -626,7 +628,8 @@ def test_spec_from_file_location_smsl_default(self):
self.assertEqual(spec.loader, self.pkgloader)
self.assertEqual(spec.origin, self.path)
self.assertIs(spec.loader_state, None)
self.assertEqual(spec.submodule_search_locations, [os.getcwd()])
location = cwd if (cwd := os.getcwd()) != '/' else ''
self.assertEqual(spec.submodule_search_locations, [location])
self.assertEqual(spec.cached, self.cached)
self.assertTrue(spec.has_location)

Expand Down

0 comments on commit 786adbc

Please sign in to comment.