Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Astafev <astafan8@gmail.com>
  • Loading branch information
jenshnielsen and astafan8 committed Oct 9, 2023
1 parent 13cfde0 commit 57e68a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion qcodes/tests/parameter/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

def test_add_ints_validator_to_parameter():
p = Parameter("test_param", set_cmd=None, get_cmd=None)
p.add_validator(Ints(min_value=0, max_value=10))
ints_val = Ints(min_value=0, max_value=10)
p.add_validator(ints_val)
assert len(p.validators) == 1
assert p.validators[0] is ints_val
assert p.vals is ints_val


def test_remove_ints_validator_from_parameter():
p = Parameter("test_param", set_cmd=None, get_cmd=None)
p.add_validator(Ints(min_value=0, max_value=10))
p.remove_validator()
assert len(p.validators) == 0
assert p.vals is None


@given(
Expand Down Expand Up @@ -54,6 +58,8 @@ def test_multiple_ints_validators(
p.add_validator(validator)

assert len(p.validators) == n_validators
if len(validators) > 0:
assert p.vals is validators[0]

if value_to_validate >= max_min_value and value_to_validate <= min_max_value:

Check notice on line 64 in qcodes/tests/parameter/test_validators.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

qcodes/tests/parameter/test_validators.py#L64

Simplify chained comparison between the operands
p.validate(value_to_validate)
Expand All @@ -63,8 +69,11 @@ def test_multiple_ints_validators(

while len(p.validators) > 0:
p.remove_validator()
if len(p.validators) > 0:
assert p.vals is p.validators[0]

assert len(p.validators) == 0
assert p.vals is None

p.validate(value_to_validate)

Expand Down

0 comments on commit 57e68a5

Please sign in to comment.