How to use the plumbum._testtools.skip_on_windows function in plumbum

To help you get started, we’ve selected a few plumbum 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 tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_path(self):
        assert not (local.cwd / "../non_exist1N9").exists()
        assert (local.cwd / ".." / "plumbum").is_dir()
        # traversal
        found = False
        for fn in local.cwd / ".." / "plumbum":
            if fn.name == "__init__.py":
                assert fn.is_file()
                found = True
        assert found
        # glob'ing
        found = False
        for fn in local.cwd / ".." // "*/*.rst":
            if fn.name == "index.rst":
                found = True
        assert found
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_iter_lines_line_timeout(self):
        from plumbum.cmd import bash
        cmd = bash["-ce", "for ((i=0;1==1;i++)); do echo $i; sleep $i; done"]

        with pytest.raises(ProcessLineTimedOut):
            # Order is important on mac
            for i, (out, err) in enumerate(cmd.popen().iter_lines(line_timeout=.2)):
                print(i, "out:", out)
                print(i, "err:", err)
        assert i == 1
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_atomic_counter2(self):
        local.path("counter").delete()
        afc = AtomicCounterFile.open("counter")
        assert afc.next() == 0
        assert afc.next() == 1
        assert afc.next() == 2

        with pytest.raises(TypeError):
            afc.reset("hello")

        afc.reset(70)
        assert afc.next() == 70
        assert afc.next() == 71
        assert afc.next() == 72

        local.path("counter").delete()
github tomerfiliba / plumbum / tests / test_env.py View on Github external
    @skip_on_windows
    def test_home(self):
        assert local.env.home == local.env["HOME"]
        old_home = local.env.home
        with local.env():
            local.env.home = "Nobody"
            assert local.env.home == local.env["HOME"]
            assert local.env.home == "Nobody"
        assert local.env.home == old_home
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    @pytest.mark.xfail(reason=
        'This test randomly fails on Mac and PyPy on Travis, not sure why')
    def test_run_tee(self, capfd):
        from plumbum.cmd import echo

        result = echo['This is fun'].run_tee()
        assert result[1] == 'This is fun\n'
        assert 'This is fun\n' == capfd.readouterr()[0]
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_popen(self):
        from plumbum.cmd import ls

        p = ls.popen(["-a"])
        out, _ = p.communicate()
        assert p.returncode == 0
        assert "test_local.py" in out.decode(local.encoding).splitlines()
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_mixing_chdir(self):
        assert local.cwd == os.getcwd()
        os.chdir('../plumbum')
        assert local.cwd == os.getcwd()
        os.chdir('../tests')
        assert local.cwd == os.getcwd()
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_env(self):
        assert "PATH" in local.env
        assert "FOOBAR72" not in local.env
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR72']")
        local.env["FOOBAR72"] = "spAm"
        assert local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines() == ["spAm"]

        with local.env(FOOBAR73 = 1889):
            assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"]
            with local.env(FOOBAR73 = 1778):
                assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1778"]
            assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"]
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR73']")
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_iter_lines_error(self):
        from plumbum.cmd import ls
        with pytest.raises(ProcessExecutionError) as err:
            for i, lines in enumerate(ls["--bla"].popen()):
                pass
            assert i == 1
        assert (err.value.stderr.startswith("/bin/ls: unrecognized option '--bla'")
                or err.value.stderr.startswith("/bin/ls: illegal option -- -"))
github tomerfiliba / plumbum / tests / test_local.py View on Github external
    @skip_on_windows
    def test_atomic_file2(self):
        af = AtomicFile("tmp.txt")

        code = """from __future__ import with_statement
from plumbum.fs.atomic import AtomicFile
af = AtomicFile("tmp.txt")
try:
    with af.locked(blocking = False):
        raise ValueError("this should have failed")
except (OSError, IOError):
    print("already locked")
"""
        with af.locked():
            output = local.python("-c", code)
            assert output.strip() == "already locked"