2
0
Fork 0

test: fix more tests for python 3.10

not sure why only that one had problems; this seems to fix
This commit is contained in:
Lance Edgar 2024-08-05 22:39:45 -05:00
parent afa3352c83
commit b5884ff6ca

View file

@ -119,15 +119,11 @@ class TestAppHandler(TestCase):
def test_get_distribution(self):
# default should always be WuttJamaican (right..?)
dist = self.app.get_distribution()
self.assertEqual(dist, 'WuttJamaican')
# also works with "non-native" objects
from config import Configuration
config = Configuration({})
dist = self.app.get_distribution(config)
self.assertEqual(dist, 'python-configuration')
# works with "non-native" objects
from sqlalchemy.orm import Query
query = Query({})
dist = self.app.get_distribution(query)
self.assertEqual(dist, 'SQLAlchemy')
# can override dist via config
self.config.setdefault('wuttatest.app_dist', 'importlib_metadata')
@ -135,8 +131,8 @@ class TestAppHandler(TestCase):
self.assertEqual(dist, 'importlib_metadata')
# but the provided object takes precedence
dist = self.app.get_distribution(config)
self.assertEqual(dist, 'python-configuration')
dist = self.app.get_distribution(query)
self.assertEqual(dist, 'SQLAlchemy')
def test_get_distribution_pre_python_3_10(self):
@ -197,19 +193,23 @@ class TestAppHandler(TestCase):
from importlib.metadata import version
# works with "non-native" objects
from config import Configuration
config = Configuration({})
ver = self.app.get_version(obj=config)
self.assertEqual(ver, version('python-configuration'))
from sqlalchemy.orm import Query
query = Query({})
ver = self.app.get_version(obj=query)
self.assertEqual(ver, version('SQLAlchemy'))
# can override dist via config
self.config.setdefault('wuttatest.app_dist', 'importlib_metadata')
self.config.setdefault('wuttatest.app_dist', 'python-configuration')
ver = self.app.get_version()
self.assertEqual(ver, version('importlib_metadata'))
self.assertEqual(ver, version('python-configuration'))
# but the provided object takes precedence
ver = self.app.get_version(obj=config)
self.assertEqual(ver, version('python-configuration'))
ver = self.app.get_version(obj=query)
self.assertEqual(ver, version('SQLAlchemy'))
# can also specify the dist
ver = self.app.get_version(dist='passlib')
self.assertEqual(ver, version('passlib'))
def test_make_title(self):
text = self.app.make_title('foo_bar')