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