Browse Source

rename load_aliases to load_mod_aliases, so that I can add a

load_aliases for raw data, such as non-package imports..
main
John-Mark Gurney 4 years ago
parent
commit
753e64f53c
2 changed files with 6 additions and 6 deletions
  1. +5
    -5
      casimport/__init__.py
  2. +1
    -1
      fixtures/randpkg/__init__.py

+ 5
- 5
casimport/__init__.py View File

@@ -201,7 +201,7 @@ class CASFinder(MetaPathFinder, Loader):
def __exit__(self, exc_type, exc_value, traceback):
self.disconnect()

def load_aliases(self, name):
def load_mod_aliases(self, name):
'''Load the aliases from the module with the passed in name.'''

aliases = importlib.resources.read_text(sys.modules[name],
@@ -337,7 +337,7 @@ def defaultinit(casf):

# The global version
_casfinder = CASFinder()
load_aliases = _casfinder.load_aliases
load_mod_aliases = _casfinder.load_mod_aliases
defaultinit(_casfinder)

import unittest
@@ -504,7 +504,7 @@ class Test(unittest.TestCase):
try:
with CASFinder() as f, \
tempattrset(sys.modules[__name__],
'load_aliases', f.load_aliases):
'load_mod_aliases', f.load_mod_aliases):
defaultinit(f)

# and that hello.py is in the cache
@@ -542,8 +542,8 @@ class Test(unittest.TestCase):

try:
with CASFinder() as f, \
tempattrset(sys.modules[__name__], 'load_aliases',
f.load_aliases):
tempattrset(sys.modules[__name__], 'load_mod_aliases',
f.load_mod_aliases):

f.register(fakeipfsloader)



+ 1
- 1
fixtures/randpkg/__init__.py View File

@@ -1,4 +1,4 @@
import casimport
casimport.load_aliases(__name__)
casimport.load_mod_aliases(__name__)

from cas.v1_a_hello import hello

Loading…
Cancel
Save