facebook / facebook/TestSlide

Can't configure TestCase

Open
#48 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted Python Unittest
Dominant language
Python
Stars
149
Forks
62
PR merge metrics
No merged PRs in 30d

Description

TestSlide has a [hacky](https://github.com/facebookincubator/TestSlide/blob/b3be3931178ae03eeae858a6ff6dca36ac8f131b/testslide/__init__.py#L93,L130) support for [`TestCase.assert*` methods](https://testslide.readthedocs.io/en/1.5.0/testslide_dsl/unittest_testcase_integration/index.html#assertions). While this works, it prevents users from tweaking things such as [`maxDiff`](https://docs.python.org/3.4/library/unittest.html#unittest.TestCase.maxDiff).

The proposed solution to fix this is:

- Drop the hacky `self._test_case`.
- Make usage of the [`TestCase integration`](https://testslide.readthedocs.io/en/1.5.0/testslide_dsl/unittest_testcase_integration/index.html#reusing-existing-unittest-testcase-setup), perhaps by adding doing [`self.add_test_case()`](https://github.com/facebookincubator/TestSlide/blob/b3be3931178ae03eeae858a6ff6dca36ac8f131b/testslide/__init__.py#L648) at [`Context.__init__`](https://github.com/facebookincubator/TestSlide/blob/b3be3931178ae03eeae858a6ff6dca36ac8f131b/testslide/__init__.py#L394), and assigning it to `self.test_case`.
- Keep the [`__getattr__`](https://github.com/facebookincubator/TestSlide/blob/b3be3931178ae03eeae858a6ff6dca36ac8f131b/testslide/__init__.py#L130) logic, but forward it to `self.test_case`.

With that, users should be able to do `self.test_case.maxDiff = new_value`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.