| 16 | class GitHubLinkTests(SimpleTestCase): |
| 17 | @classmethod |
| 18 | def setUpClass(cls): |
| 19 | # The file implementing the code under test is in the docs folder and |
| 20 | # is not part of the Django package. This means it cannot be imported |
| 21 | # through standard means. Include its parent in the pythonpath for the |
| 22 | # duration of the tests to allow the code to be imported. |
| 23 | cls.ext_path = str((pathlib.Path(__file__).parents[2] / "docs/_ext").resolve()) |
| 24 | sys.path.insert(0, cls.ext_path) |
| 25 | cls.addClassCleanup(sys.path.remove, cls.ext_path) |
| 26 | cls.addClassCleanup(sys.modules.pop, "github_links", None) |
| 27 | # Linters/IDEs may not be able to detect this as a valid import. |
| 28 | import github_links as _github_links |
| 29 | |
| 30 | global github_links |
| 31 | github_links = _github_links |
| 32 | |
| 33 | def test_code_locator(self): |
| 34 | locator = github_links.CodeLocator.from_code(""" |