Skip to content

Commit

Permalink
Add test capturing the current behavior. Ref #106.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 22, 2024
1 parent bc7fbf5 commit 966d86b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pip_run/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,) = (
Expand Down
9 changes: 9 additions & 0 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down

0 comments on commit 966d86b

Please sign in to comment.