How to use the distro._UNIXCONFDIR function in distro

To help you get started, we’ve selected a few distro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nir0s / distro / tests / test_distro.py View on Github external
def _setup_for_distro(self, distro_root):
        distro_bin = os.path.join(distro_root, 'bin')
        # We don't want to pick up a possibly present lsb_release in the
        # distro that runs this test, so we use a PATH with only one entry:
        os.environ["PATH"] = distro_bin
        distro._UNIXCONFDIR = os.path.join(distro_root, RELATIVE_UNIXCONFDIR)
github nir0s / distro / tests / test_ld.py View on Github external
def tearDown(self):
        super(DistroTestCase, self).tearDown()
        os.environ["PATH"] = self._saved_path
        distro._UNIXCONFDIR = self._saved_UNIXCONFDIR
github nir0s / distro / tests / test_ld.py View on Github external
def _setup_for_distro(self, distro_root):
        distro_bin = os.path.join(os.getcwd(), distro_root, 'bin')
        # We don't want to pick up a possibly present lsb_release in the
        # distro that runs this test, so we use a PATH with only one entry:
        os.environ["PATH"] = distro_bin
        distro._UNIXCONFDIR = os.path.join(distro_root, RELATIVE_UNIXCONFDIR)
github nir0s / distro / tests / test_ld.py View on Github external
import subprocess
try:
    from StringIO import StringIO  # Python 2.x
except ImportError:
    from io import StringIO  # Python 3.x


import distro


RESOURCES = os.path.join('tests', 'resources')
DISTROS = os.path.join(RESOURCES, 'distros')
TESTDISTROS = os.path.join(RESOURCES, 'testdistros')
SPECIAL = os.path.join(RESOURCES, 'special')

RELATIVE_UNIXCONFDIR = distro._UNIXCONFDIR.lstrip('/')

MODULE_DISTROI = distro._distroi


class DistroTestCase(testtools.TestCase):
    """A base class for any testcase classes that test the distributions
    represented in the `DISTROS` subtree."""

    def setUp(self):
        super(DistroTestCase, self).setUp()
        # The environment stays the same across all testcases, so we
        # save and restore the PATH env var in each test case that
        # changes it:
        self._saved_path = os.environ["PATH"]
        self._saved_UNIXCONFDIR = distro._UNIXCONFDIR
github nir0s / distro / tests / test_distro.py View on Github external
def teardown_method(self, test_method):
        os.environ["PATH"] = self._saved_path
        distro._UNIXCONFDIR = self._saved_UNIXCONFDIR
github nir0s / distro / tests / test_distro.py View on Github external
import pytest


BASE = os.path.abspath(os.path.dirname(__file__))
RESOURCES = os.path.join(BASE, 'resources')
DISTROS_DIR = os.path.join(RESOURCES, 'distros')
TESTDISTROS = os.path.join(RESOURCES, 'testdistros')
SPECIAL = os.path.join(RESOURCES, 'special')
DISTROS = [dist for dist in os.listdir(DISTROS_DIR) if dist != '__shared__']


IS_LINUX = sys.platform.startswith('linux')
if IS_LINUX:
    import distro

    RELATIVE_UNIXCONFDIR = distro._UNIXCONFDIR[1:]
    MODULE_DISTRO = distro._distro


class TestNonLinuxPlatform:
    """Obviously, this only tests Windows. Will add OS X tests on Travis
    Later
    """

    def test_cant_use_on_windows(self):
        try:
            import distro  # NOQA
        except ImportError as ex:
            assert 'Unsupported platform' in str(ex)


@pytest.mark.skipif(not IS_LINUX, reason='Irrelevant on non-linux')
github nir0s / distro / tests / test_distro.py View on Github external
def setup_method(self, test_method):
        # The environment stays the same across all testcases, so we
        # save and restore the PATH env var in each test case that
        # changes it:
        self._saved_path = os.environ["PATH"]
        self._saved_UNIXCONFDIR = distro._UNIXCONFDIR
github nir0s / distro / tests / test_ld.py View on Github external
def setUp(self):
        super(DistroTestCase, self).setUp()
        # The environment stays the same across all testcases, so we
        # save and restore the PATH env var in each test case that
        # changes it:
        self._saved_path = os.environ["PATH"]
        self._saved_UNIXCONFDIR = distro._UNIXCONFDIR