Esempio n. 1
0
 def test_in_range_inclusive(self):
     """
     Tests that on inclusive ranges, values that are in the range
     are valid.
     """
     instance = Range('@10:20')
     assert instance.in_range(15)
Esempio n. 2
0
 def test_in_range_inclusive_equal_to_end(self):
     """
     Tests that on inclusive ranges, values that are equal to
     the end are valid.
     """
     instance = Range('@10:20')
     assert instance.in_range(20)
Esempio n. 3
0
 def test_in_range_inclusive(self):
     """
     Tests that on inclusive ranges, values that are in the range
     are valid.
     """
     instance = Range('@10:20')
     assert instance.in_range(15)
Esempio n. 4
0
 def test_in_range_inclusive_equal_to_end(self):
     """
     Tests that on inclusive ranges, values that are equal to
     the end are valid.
     """
     instance = Range('@10:20')
     assert instance.in_range(20)
Esempio n. 5
0
 def test_valid_warn_range_as_range(self):
     """
     Tests to verify that warning range can be set to range object.
     """
     value = Range("10:20")
     instance = PerfData("foo", "7", warn=value)
     assert value == instance.warn
Esempio n. 6
0
 def test_range_with_only_beginning(self):
     """
     Tests ranges with only a beginning are parsed properly.
     """
     instance = Range('10:')
     assert 10.0 == instance.start
     assert float("inf") == instance.end
Esempio n. 7
0
 def test_range_with_end_smaller_than_start(self):
     """
     Tests that ranges which have an end larger than the start
     are invalid.
     """
     with pytest.raises(RangeValueError):
         Range('20:10')
Esempio n. 8
0
 def test_valid_crit_range_as_range(self):
     """
     Tests to verify that crit range can be set to range object.
     """
     value = Range("10:20")
     instance = PerfData("foo", "7", crit=value)
     assert value == instance.crit
Esempio n. 9
0
 def test_range_with_inclusive(self):
     """
     Tests that a range can be inclusive.
     """
     instance = Range('@10:20')
     assert 10.0 == instance.start
     assert 20.0 == instance.end
     assert instance.inclusive
Esempio n. 10
0
 def test_range_with_equal_start_and_small(self):
     """
     Tests that the start and end can be equal.
     """
     instance = Range('10:10')
     assert 10.0 == instance.start
     assert 10.0 == instance.end
     assert not instance.inclusive
Esempio n. 11
0
 def test_range_with_positive_inf(self):
     """
     Tests that positive infinity is a valid end.
     """
     instance = Range('10:~')
     assert 10.0 == instance.start
     assert float("inf") == instance.end
     assert not instance.inclusive
Esempio n. 12
0
 def test_range_as_string(self):
     """
     Tests that the range can be converted back to a valid string
     format.
     """
     tests = ["10", "10:20", "20", "~:10", "@10:15", "@~:~", "10:~"]
     for test in tests:
         assert test == str(Range(test))
Esempio n. 13
0
 def test_range_with_negative_inf(self):
     """
     Tests that negative infinity is valid for start.
     """
     instance = Range('~:20')
     assert float("-inf") == instance.start
     assert 20.0 == instance.end
     assert not instance.inclusive
Esempio n. 14
0
 def test_range_with_only_end(self):
     """
     Tests ranges with only an end value, such as '10'
     """
     instance = Range('10')
     assert 0.0 == instance.start
     assert 10.0 == instance.end
     assert not instance.inclusive
Esempio n. 15
0
 def test_range_with_both(self):
     """
     Tests ranges with a valid float for start and end and
     ensures they are valid.
     """
     instance = Range('10:20')
     assert 10.0 == instance.start
     assert 20.0 == instance.end
     assert not instance.inclusive
Esempio n. 16
0
 def test_range_with_empty_start(self):
     """
     Tests ranges with an empty start value.
     """
     with pytest.raises(RangeValueError):
         Range(':10')
Esempio n. 17
0
 def test_in_range_below_valid(self):
     """
     Tests that values outside the lower end of the range are valid.
     """
     instance = Range('10:20')
     assert instance.in_range(9)
Esempio n. 18
0
 def test_in_range_above_valid(self):
     """
     Tests that values outside the upper end of the range are valid.
     """
     instance = Range('10:20')
     assert instance.in_range(21)
Esempio n. 19
0
 def test_in_range_exclusive_equal_to_end_invalid(self):
     """
     Tests that exclusive ranges do not count the end value.
     """
     instance = Range('10:20')
     assert not instance.in_range(20)
Esempio n. 20
0
 def test_in_range_below_valid(self):
     """
     Tests that values outside the lower end of the range are valid.
     """
     instance = Range('10:20')
     assert instance.in_range(9)
Esempio n. 21
0
 def test_range_with_empty(self):
     """
     Tests empty ranges should throw an error.
     """
     with pytest.raises(RangeValueError):
         Range('')
Esempio n. 22
0
 def test_range_with_too_many_values(self):
     """
     Tests ranges with too many values throws an error.
     """
     with pytest.raises(RangeValueError):
         Range("10:20:30")
Esempio n. 23
0
 def test_in_range_exclusive_equal_to_end_invalid(self):
     """
     Tests that exclusive ranges do not count the end value.
     """
     instance = Range('10:20')
     assert not instance.in_range(20)
Esempio n. 24
0
 def test_range_with_bad_start(self):
     """
     Tests ranges with a bad start value are invalid.
     """
     with pytest.raises(RangeValueError):
         Range('bad:10')
Esempio n. 25
0
 def test_in_range_above_valid(self):
     """
     Tests that values outside the upper end of the range are valid.
     """
     instance = Range('10:20')
     assert instance.in_range(21)
Esempio n. 26
0
 def test_range_with_bad_end(self):
     """
     Tests ranges with a bad end value are invalid.
     """
     with pytest.raises(RangeValueError):
         Range('10:bad')