|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 |
| - |
15 | 14 | """Module containing canned measurement validators.
|
16 | 15 |
|
17 | 16 | Additional validators may be registered by passing them to the Register()
|
@@ -246,8 +245,8 @@ def all_equals(value, type=None): # pylint: disable=redefined-builtin
|
246 | 245 | if isinstance(value, numbers.Number):
|
247 | 246 | return AllInRangeValidator(minimum=value, maximum=value)
|
248 | 247 | elif isinstance(value, str):
|
249 |
| - assert type is None or issubclass(type, str), ( |
250 |
| - 'Cannot use a non-string type when matching a string') |
| 248 | + assert type is None or issubclass( |
| 249 | + type, str), ('Cannot use a non-string type when matching a string') |
251 | 250 | return matches_regex('^{}$'.format(re.escape(value)))
|
252 | 251 | else:
|
253 | 252 | return AllEqualsValidator(value)
|
@@ -385,8 +384,8 @@ def equals(value, type=None): # pylint: disable=redefined-builtin
|
385 | 384 | if isinstance(value, numbers.Number):
|
386 | 385 | return InRange(minimum=value, maximum=value, type=type)
|
387 | 386 | elif isinstance(value, str):
|
388 |
| - assert type is None or issubclass(type, str), ( |
389 |
| - 'Cannot use a non-string type when matching a string') |
| 387 | + assert type is None or issubclass( |
| 388 | + type, str), ('Cannot use a non-string type when matching a string') |
390 | 389 | return matches_regex('^{}$'.format(re.escape(value)))
|
391 | 390 | else:
|
392 | 391 | return Equals(value, type=type)
|
@@ -449,10 +448,10 @@ def __init__(self, expected, percent, marginal_percent=None) -> None:
|
449 | 448 | super(WithinPercent, self).__init__()
|
450 | 449 | if percent < 0:
|
451 | 450 | raise ValueError('percent argument is {}, must be >0'.format(percent))
|
452 |
| - if marginal_percent is not None and marginal_percent < percent: |
| 451 | + if marginal_percent is not None and marginal_percent >= percent: |
453 | 452 | raise ValueError(
|
454 |
| - 'marginal_percent argument is {}, must be < percent'.format( |
455 |
| - marginal_percent)) |
| 453 | + 'marginal_percent argument is {}, must be < {} percent'.format( |
| 454 | + marginal_percent, percent)) |
456 | 455 | self.expected = expected
|
457 | 456 | self.percent = percent
|
458 | 457 | self.marginal_percent = marginal_percent
|
@@ -481,7 +480,7 @@ def marginal_minimum(self):
|
481 | 480 |
|
482 | 481 | @property
|
483 | 482 | def marginal_maximum(self):
|
484 |
| - return (self.expected - |
| 483 | + return (self.expected + |
485 | 484 | self._applied_marginal_percent if self.marginal_percent else None)
|
486 | 485 |
|
487 | 486 | def __call__(self, value) -> bool:
|
|
0 commit comments