How to use setupmeta - 10 common examples

To help you get started, we’ve selected a few setupmeta 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 zsimic / setupmeta / tests / test_versioning.py View on Github external
def test_brand_new_project():
    with setupmeta.temp_resource():
        conftest.run_git("init")
        with open("setup.py", "w") as fh:
            fh.write(SAMPLE_EMPTY_PROJECT)

        # Test that we avoid warning about no tags etc on brand new empty git repos
        output = setupmeta.run_program(sys.executable, "setup.py", "--version", capture="all")
        output = conftest.cleaned_output(output)
        assert output == "0.0.0"
github zsimic / setupmeta / tests / scenarios.py View on Github external
os.makedirs(self.origin)
        self.run_git("init", "--bare", self.origin, cwd=self.temp)
        self.run_git("clone", self.origin, self.target, cwd=self.temp)
        copytree(self.folder, self.target)

        for command in self.preparation:
            if command.startswith("mv"):
                # Unfortunately there is no 'mv' on Windows
                _, source, dest = command.split()
                source = os.path.join(self.target, source)
                dest = os.path.join(self.target, dest)
                shutil.copytree(source, dest)
                shutil.rmtree(source)

            else:
                setupmeta.run_program(*command.split(), cwd=self.target)

        self.run_git("add", ".")
        self.run_git("commit", "-m", "Initial commit")
        self.run_git("push", "origin", "master")
        self.run_git("tag", "-a", "v1.2.3", "-m", "Initial tag at v1.2.3")
        self.run_git("push", "--tags", "origin", "master")
github zsimic / setupmeta / tests / test_commands.py View on Github external
def from_string(self, specs):
        result = []
        for spec in specs.split():
            name, _, req = spec.partition(":")
            if req:
                req = [setupmeta.pkg_req(r) for r in req.split("+")]
            else:
                req = []
            result.append(FakeDist(name, req))
        return result
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_meta_command_init():
    with pytest.raises(Exception):
        obj = setupmeta.MetaDefs()
        setupmeta.meta_command_init(obj, {})
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_run_program():
    setupmeta.DEBUG = True
    with conftest.capture_output() as out:
        assert setupmeta.run_program("ls", capture=True, dryrun=True) is None
        assert setupmeta.run_program("ls", capture=False, dryrun=True) == 0
        assert setupmeta.run_program("ls", "foo/does/not/exist", capture=None) != 0
        assert setupmeta.run_program("pip", "--version", capture=True)
        assert setupmeta.run_program("pip", "foo bar", capture=True) == ""
        assert "unknown command" in setupmeta.run_program("pip", "foo bar", capture="all")
        assert setupmeta.run_program("/foo/does/not/exist", capture=True, dryrun=True) is None
        assert setupmeta.run_program("/foo/does/not/exist", capture=False) != 0

        with pytest.raises(SystemExit):
            setupmeta.run_program("/foo/does/not/exist", fatal=True)

        with pytest.raises(SystemExit):
            assert setupmeta.run_program("ls", "foo/does/not/exist", fatal=True)

        assert "exitcode" in out

    setupmeta.DEBUG = False
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_run_program():
    setupmeta.DEBUG = True
    with conftest.capture_output() as out:
        assert setupmeta.run_program("ls", capture=True, dryrun=True) is None
        assert setupmeta.run_program("ls", capture=False, dryrun=True) == 0
        assert setupmeta.run_program("ls", "foo/does/not/exist", capture=None) != 0
        assert setupmeta.run_program("pip", "--version", capture=True)
        assert setupmeta.run_program("pip", "foo bar", capture=True) == ""
        assert "unknown command" in setupmeta.run_program("pip", "foo bar", capture="all")
        assert setupmeta.run_program("/foo/does/not/exist", capture=True, dryrun=True) is None
        assert setupmeta.run_program("/foo/does/not/exist", capture=False) != 0

        with pytest.raises(SystemExit):
            setupmeta.run_program("/foo/does/not/exist", fatal=True)

        with pytest.raises(SystemExit):
            assert setupmeta.run_program("ls", "foo/does/not/exist", fatal=True)

        assert "exitcode" in out

    setupmeta.DEBUG = False
github zsimic / setupmeta / tests / test_content.py View on Github external
setupmeta.DEBUG = True
    with conftest.capture_output() as out:
        assert setupmeta.run_program("ls", capture=True, dryrun=True) is None
        assert setupmeta.run_program("ls", capture=False, dryrun=True) == 0
        assert setupmeta.run_program("ls", "foo/does/not/exist", capture=None) != 0
        assert setupmeta.run_program("pip", "--version", capture=True)
        assert setupmeta.run_program("pip", "foo bar", capture=True) == ""
        assert "unknown command" in setupmeta.run_program("pip", "foo bar", capture="all")
        assert setupmeta.run_program("/foo/does/not/exist", capture=True, dryrun=True) is None
        assert setupmeta.run_program("/foo/does/not/exist", capture=False) != 0

        with pytest.raises(SystemExit):
            setupmeta.run_program("/foo/does/not/exist", fatal=True)

        with pytest.raises(SystemExit):
            assert setupmeta.run_program("ls", "foo/does/not/exist", fatal=True)

        assert "exitcode" in out

    setupmeta.DEBUG = False
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_stringify():
    assert setupmeta.stringify((1, 2)) == '("1", "2")'
    assert setupmeta.stringify(["1", "2"]) == '["1", "2"]'
    assert setupmeta.stringify(("a b", "c d")) == '("a b", "c d")'

    assert setupmeta.stringify("""quoted ("double"+'single')""", quote=True) == """'quoted ("double"+'single')'"""
    assert setupmeta.stringify("""quoted 'single only'""", quote=True) == '''"quoted 'single only'"'''
    assert setupmeta.stringify("no 'foo'") == "no 'foo'"
    assert setupmeta.stringify("no 'foo'", quote=True) == '''"no 'foo'"'''

    assert setupmeta.stringify({"bar": "no 'foo'"}) == """{bar: no 'foo'}"""
    assert setupmeta.stringify({"bar": 'no "foo"'}) == """{bar: no "foo"}"""

    assert setupmeta.listify("a b") == ["a", "b"]
    assert sorted(setupmeta.listify(set("ab"))) == ["a", "b"]
    assert setupmeta.listify(("a", "b")) == ["a", "b"]
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_shortening():
    assert setupmeta.short(None) == "None"
    assert setupmeta.short("") == ""

    assert setupmeta.short("hello  there", c=13) == "hello there"
    assert setupmeta.short("hello  there", c=12) == "hello there"
    assert setupmeta.short("hello  there", c=11) == "hello there"
    assert setupmeta.short("hello  there", c=10) == "hello t..."
    assert setupmeta.short("hello  there", c=-10) == "hello ther..."
    assert setupmeta.short("hello there wild wonderful world", c=19) == "hello there wild..."
    assert setupmeta.short("hello there wild wonderful world", c=-19) == "hello there wild wo..."

    assert setupmeta.short(["hello", "there", "wild", "wonderful  world"], c=34) == '4 items: ["hello", "there", "wi...'

    path = os.path.expanduser("~/foo/bar")
    assert setupmeta.short(path) == "~/foo/bar"

    assert setupmeta.short("found in %s" % path) == "found in ~/foo/bar"

    assert setupmeta.short(dict(foo="bar"), c=8) == "1 keys"

    assert setupmeta.merged("a", None) == "a"
    assert setupmeta.merged(None, "a") == "a"
    assert setupmeta.merged("a", "b") == "a\nb"
github zsimic / setupmeta / tests / test_content.py View on Github external
def test_shortening():
    assert setupmeta.short(None) == "None"
    assert setupmeta.short("") == ""

    assert setupmeta.short("hello  there", c=13) == "hello there"
    assert setupmeta.short("hello  there", c=12) == "hello there"
    assert setupmeta.short("hello  there", c=11) == "hello there"
    assert setupmeta.short("hello  there", c=10) == "hello t..."
    assert setupmeta.short("hello  there", c=-10) == "hello ther..."
    assert setupmeta.short("hello there wild wonderful world", c=19) == "hello there wild..."
    assert setupmeta.short("hello there wild wonderful world", c=-19) == "hello there wild wo..."

    assert setupmeta.short(["hello", "there", "wild", "wonderful  world"], c=34) == '4 items: ["hello", "there", "wi...'

    path = os.path.expanduser("~/foo/bar")
    assert setupmeta.short(path) == "~/foo/bar"

    assert setupmeta.short("found in %s" % path) == "found in ~/foo/bar"

    assert setupmeta.short(dict(foo="bar"), c=8) == "1 keys"

    assert setupmeta.merged("a", None) == "a"
    assert setupmeta.merged(None, "a") == "a"