Skip to content

Commit

Permalink
✏️ Reformat source code with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobronium committed Nov 11, 2024
1 parent 212ce4f commit 4aa2fa6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion parametrize/parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_a_and_b(self, a, b):
parameters, argnames_set = _collect_parameters(argnames, argvalues)

def decorator(
func_or_context: Union[FunctionType, ParametrizeContext]
func_or_context: Union[FunctionType, ParametrizeContext],
) -> Union[ParametrizeContext, UnparametrizedMethod]:
if isinstance(func_or_context, UnparametrizedMethod): # we should never end up here
raise RuntimeError(
Expand Down
4 changes: 2 additions & 2 deletions parametrize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def copy_func(f: FunctionType, name, defaults, signature: Signature):
new_defaults.append(defaults.pop(key))
elif param.default is not param.empty:
new_defaults.append(param.default)

original_code = f.__code__
code_replacements = {"co_name": name}
if hasattr(original_code, "co_qualname"):
*path, _old_name = original_code.co_qualname.rsplit(".", maxsplit=1)
path.append(name)
code_replacements["co_qualname"] = ".".join(path)

new_func = FunctionType(
code=copy_code(original_code, **code_replacements),
globals=f.__globals__,
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from parametrize import parametrize

class TestSomething(unittest.TestCase):

@parametrize('test_input,expected', [("3+5", 8), ("2+4", 6)])
@parametrize('test_input,expected', [("3+5", 8), ("2+4", 6), ("6*9", 42)])
def test_eval(self, test_input, expected):
self.assertEqual(expected, eval(test_input))
```
Expand Down

0 comments on commit 4aa2fa6

Please sign in to comment.