Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"]
def test_listify():
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,\n b", separator=",") == ["a", "b"]
assert setupmeta.listify("a\n b", separator=",") == ["a", "b"]
def test_listify():
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,\n b", separator=",") == ["a", "b"]
assert setupmeta.listify("a\n b", separator=",") == ["a", "b"]
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"]
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"]
def test_listify():
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,\n b", separator=",") == ["a", "b"]
assert setupmeta.listify("a\n b", separator=",") == ["a", "b"]
def test_listify():
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b") == ["a,", "b"]
assert setupmeta.listify("a, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,, b", separator=",") == ["a", "b"]
assert setupmeta.listify("a,\n b", separator=",") == ["a", "b"]
assert setupmeta.listify("a\n b", separator=",") == ["a", "b"]
self.main_bits = self.bits(main)
if isinstance(self.main_bits, list):
self.bumpable = [b.text for b in self.main_bits if b.text in BUMPABLE]
else:
self.bumpable = []
self.extra_bits = self.bits(extra)
self.separator = separator
self.branches = branches
self.hook = hook
if self.branches and hasattr(self.branches, "lstrip"):
self.branches = self.branches.lstrip("(").rstrip(")")
self.branches = setupmeta.listify(self.branches, separator=",")
self.text = self.formatted(self.branches, self.main, self.separator, self.extra)
if not self.main_bits:
self.problem = "No versioning format specified"
return
all_bits = self.main_bits if isinstance(self.main_bits, list) else []
if isinstance(self.extra_bits, list):
all_bits = all_bits + self.extra_bits
problems = [bit.problem for bit in all_bits if bit.problem]
self.problem = "\n".join(problems) if problems else None
def add_definition(self, key, value, source, override=False):
"""
:param str key: Key being defined
:param value: Value to add (first value wins, unless override used)
:param str source: Where this key/value came from
:param bool override: If True, 'value' is forcibly taken
"""
if key and (value or override):
if key in ("keywords", "setup_requires"):
value = listify(value, separator=",")
definition = self.definitions.get(key)
if definition is None:
definition = Definition(key)
self.definitions[key] = definition
definition.add(value, source, override=override)