diff --git a/pip_run/scripts.py b/pip_run/scripts.py index 95f1e36..b42f584 100644 --- a/pip_run/scripts.py +++ b/pip_run/scripts.py @@ -162,7 +162,8 @@ def _read(self, var_name): """ Read a variable from self.script by parsing the AST. - Raises ValueError if the variable is not found. + Raises ValueError if the variable is not found or if it + appears more than once. """ mod = ast.parse(self.script) (node,) = ( diff --git a/tests/test_scripts.py b/tests/test_scripts.py index 877c0a5..0326b4c 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -56,6 +56,15 @@ def test_reads_files_with_attribute_assignment(self): ) assert scripts.DepsReader(script).read() == ['foo'] + def test_duplicate_definition(self): + script = textwrap.dedent( + """ + __requires__=['foo'] + __requires__=['bar'] + """ + ) + assert scripts.DepsReader(script).read() == [] + def test_reads_files_with_multiple_assignment(self): script = textwrap.dedent( """