Skip to content

Commit 32da58a

Browse files
committed
Regression-test support for deprecated import patterns
1 parent f24f579 commit 32da58a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_package.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Tests for work-arounds to known arXiv API bugs.
3+
"""
4+
import unittest
5+
from typing import Set
6+
7+
8+
# ruff: noqa: F401
9+
class TestPackage(unittest.TestCase):
10+
def get_public_classes(module: object) -> Set[str]:
11+
"""
12+
Bodge: filter for the portion of the namespace that looks like exports.
13+
"""
14+
return {name for name in dir(module) if name[0].isupper()}
15+
16+
def test_deprecated_import_pattern(self):
17+
import arxiv as nondeprecated
18+
19+
expected = TestPackage.get_public_classes(nondeprecated)
20+
self.assertTrue(
21+
expected, "should export non-empty set of classes; check the helper"
22+
)
23+
24+
from arxiv import arxiv as deprecated_from
25+
26+
self.assertSetEqual(expected, TestPackage.get_public_classes(deprecated_from))
27+
28+
import arxiv.arxiv as deprecated_dot
29+
30+
self.assertSetEqual(expected, TestPackage.get_public_classes(deprecated_dot))

0 commit comments

Comments
 (0)