1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
import os
import unittest
from copy import deepcopy
from tempfile import TemporaryDirectory
from dhpython.depends import Dependencies
from dhpython.fs import ScanResult
from dhpython.options import DHPythonOptions
from dhpython.pydist import Standard
from .test_depends import prime_pydist, pydist
class TestDistutilsExtra(unittest.TestCase):
options = DHPythonOptions(guess_deps=True)
pydist = {
"bar": [pydist(name="bar", dependency="python3-bar")],
"baz": [pydist(name="baz", dependency="python3-baz", standard=Standard.PEP386)],
"quux": [
pydist(name="quux", dependency="python3-quux", standard=Standard.PEP386)
],
}
pkg = "foo"
impl = "cpython3"
stats = ScanResult(
{
"compile": False,
"dist-info": set(),
"egg-info": {"PKG-INFO"},
"ext_no_version": set(),
"ext_stableabi": set(),
"ext_vers": set(),
"nsp.txt": set(),
"private_dirs": {},
"public_vers": set(),
"requires.txt": set(),
"shebangs": set(),
}
)
def test_depends_on_bar(self) -> None:
self.d = Dependencies(self.pkg, self.impl)
stats = deepcopy(self.stats)
self.tempdir = TemporaryDirectory() # pylint: disable=consider-using-with
self.addCleanup(self.tempdir.cleanup)
old_wd = os.getcwd()
os.chdir(self.tempdir.name)
self.addCleanup(os.chdir, old_wd)
with open(self.tempdir.name + "/PKG-INFO", "w", encoding="UTF-8") as f:
f.write(
"""Metadata-Version: 2.1
Name: gTranscribe
Version: 0.11
Summary: gTranscribe
Home-page: https://github.com/innir/gtranscribe
Author: Philip Rinn
Author-email: rinni@inventati.org
License: GPL-3
Requires: bar
gTranscribe is a software focused on easy transcription of spoken words.
"""
)
cleanup = prime_pydist(self.impl, self.pydist)
self.addCleanup(cleanup)
self.d.parse(stats, self.options)
self.assertIn("python3-bar", self.d.depends)
|