|
1 |
| -import sys |
2 |
| -import unittest |
3 | 1 | from unittest.mock import Mock
|
4 | 2 |
|
5 | 3 | import pytest
|
@@ -437,99 +435,3 @@ def assert_action_performed_with(_widget, _action, **test_data):
|
437 | 435 | except AttributeError as e:
|
438 | 436 | # None of the recorded actions match the test data.
|
439 | 437 | pytest.fail(str(e))
|
440 |
| - |
441 |
| - |
442 |
| -########################################################################### |
443 |
| -# Unittest widget assertions |
444 |
| -# |
445 |
| -# These have been (re)written in terms of Pytest assertions; this base |
446 |
| -# class is deprecated and should not be used for new tests. |
447 |
| -############################################################################ |
448 |
| -class TestCase(unittest.TestCase): |
449 |
| - def setUp(self): |
450 |
| - EventLog.reset() |
451 |
| - |
452 |
| - # We use the existence of a __main__ module as a proxy for being in test |
453 |
| - # conditions. This isn't *great*, but the __main__ module isn't meaningful |
454 |
| - # during tests, and removing it allows us to avoid having explicit "if |
455 |
| - # under test conditions" checks in paths.py. |
456 |
| - if "__main__" in sys.modules: |
457 |
| - del sys.modules["__main__"] |
458 |
| - |
459 |
| - def reset_event_log(self): |
460 |
| - EventLog.reset() |
461 |
| - |
462 |
| - def pytest_assert(self, assertion, *args, **kwargs): |
463 |
| - try: |
464 |
| - return assertion(*args, **kwargs) |
465 |
| - except AssertionError as e: |
466 |
| - self.fail(str(e)) |
467 |
| - |
468 |
| - ##### |
469 |
| - |
470 |
| - def assertValueSet(self, _widget, _attr, value): |
471 |
| - """Assert that the widget implementation has set an attribute to a value. |
472 |
| -
|
473 |
| - Args: |
474 |
| - _widget: The interface of the widget to check |
475 |
| - _attr: The attribute that should have been set |
476 |
| - value: The value that the attribute have been set to. |
477 |
| - """ |
478 |
| - self.assertEqual(self.pytest_assert(attribute_value, _widget, _attr), value) |
479 |
| - |
480 |
| - def assertValuesSet(self, _widget, _attr, values): |
481 |
| - """Assert that the widget implementation has been set to multiple values. |
482 |
| -
|
483 |
| - Args: |
484 |
| - _widget: The interface of the widget to check |
485 |
| - _attr: The attribute that should have been set |
486 |
| - values: The values that the attribute have been set to. |
487 |
| - """ |
488 |
| - self.assertEqual(self.pytest_assert(attribute_values, _widget, _attr), values) |
489 |
| - |
490 |
| - def assertValueGet(self, _widget, _attr): |
491 |
| - """Assert that the widget implementation attempted to retrieve an attribute. |
492 |
| -
|
493 |
| - Args: |
494 |
| - _widget: The interface of the widget to check |
495 |
| - _attr: The attribute that should have been retrieved |
496 |
| - """ |
497 |
| - self.pytest_assert(assert_attribute_retrieved, _widget, _attr) |
498 |
| - |
499 |
| - def assertValueNotGet(self, _widget, _attr): |
500 |
| - self.pytest_assert(assert_attribute_not_retrieved, _widget, _attr) |
501 |
| - |
502 |
| - def assertValueNotSet(self, _widget, _attr): |
503 |
| - self.pytest_assert(assert_attribute_not_set, _widget, _attr) |
504 |
| - |
505 |
| - def assertActionNotPerformed(self, _widget, _action): |
506 |
| - """Assert that the named action was *not* performed by a widget. |
507 |
| -
|
508 |
| - Args: |
509 |
| - _widget: The interface of the widget that should not have performed the action. |
510 |
| - _action: The name of the action to check |
511 |
| - """ |
512 |
| - self.pytest_assert(assert_action_not_performed, _widget, _action) |
513 |
| - |
514 |
| - def assertActionPerformed(self, _widget, _action): |
515 |
| - """Assert that the named action performed by a widget. |
516 |
| -
|
517 |
| - Args: |
518 |
| - _widget: The interface of the widget that should have performed the action. |
519 |
| - _action: The name of the action to check |
520 |
| - """ |
521 |
| - self.pytest_assert(assert_action_performed, _widget, _action) |
522 |
| - |
523 |
| - def assertActionPerformedWith(self, _widget, _action, **test_data): |
524 |
| - """Was the action performed with specific test data. |
525 |
| -
|
526 |
| - Args: |
527 |
| - _widget: The interface of the widget that should have performed the action. |
528 |
| - _action: The name of the action to check. |
529 |
| - **test_data: The arguments that should have been passed to the action. |
530 |
| -
|
531 |
| - Returns: |
532 |
| - If a matching action was performed, the full data of |
533 |
| - the performed action if. False otherwise. |
534 |
| - """ |
535 |
| - self.pytest_assert(assert_action_performed_with, _widget, _action, **test_data) |
0 commit comments