Comments (5)
After some thoughts, here is the interface that I could suggest:
-
first, this special decorator should never be merged in PRs unless there's a good reason (but I don't see which reason we could have since it would only be used with mixin classes parametrized by different interfaces)
-
since most of the time, everything is based according to a class attribute of the mixin class, it'd be easier to use:
# skip if 'self.something' raises AttributeError, # or if the C implementation of 'self.something' is missing. @test.support.ignore_missing_impl(something="c") def test_something(self): x = self.something(...)
I still don't know how to elegantly skip tests where a method is not implemented in C but is implemented in Python without having a complex interface. One idea is to have some generic predicate like:
def test(self):
x = self.something_in_c_and_python(...)
# assume that x.foo() exists only in Python
# would call self.skipTest() if x.c does not exist
# and if x is an object from a C module instead.
# Usually the files import both the C and Python implementations,
# so we could check whether x is from the C or the Python implementation like that.
test.support.check_support(self, x, c='foo', pymodule=_pymodule, cmodule=_cmodule)
y = x.foo()
from cpython.
I think you should just comment out or explicitly skip tests that are currently inapplicable. As you add pieces of the C implementation, you want them tested, so uncomment/unskip that tests that should pass with the new code addition.
from cpython.
@terryjreedy Actually, after a good sleep, I observed that a simpler solution is just to add a check inside the test like
if self.myclass is not _pyio.BytesIO:
self.skipTest("TODO")
Ideally, I'd like to have the possibility of having self.skipIf(self.myclass is not _pyio.BytesIO)
but there is only a skipIf
decorator and not a skipIf
method. Would it make sense to expose some skipIf
method to the unittest
class as well?
Anyway, I'll close this one as not planned.
from cpython.
I don't see the purpose of a method. What would it skip? The decorator skips what it contains and skipTest skips what contains it. That seems to cover the needed cases pretty well.
from cpython.
The issue with the decorator is that I cannot make it skip something that depends on an attribute, i.e., I cannot use self
of something (at least, I don't see how I can put a skipIf
decorator on a base class method which is then inherited by C or Python interfaces).
Maybe an example would be more explicit:
class MixinClass:
myclass = None
def test_this(self):
x = self.myclass(...)
def test_incomplete_component_for_now(self):
# test is implementation agnostic
if self.myclass is not MyPythonClass:
self.skipTest("not ready for this test")
# I would like to use `skipIf` like that:
def test_incomplete_component_for_now_with_skipif(self):
# self.skipIf does not exist as method on test cases!
# and I cannot use the decorator on base mixin classes
self.skipIf(self.myclass is not MyPythonClass)
class PythonTestSuite(MixinClass):
myclass = MyPythonClass
class CTestSuite(MixinClass):
myclass = MyCClass
Note that I don't want to disable the entire test suite of C classes, just specific tests on mixin classes, but I expected that skipIf
would also be available as a method actually (it's more synctatic sugar but I understand if you don't want that additional interface).
from cpython.
Related Issues (20)
- Incoming.md
- Freethreading interpreter will attempt to import unsupported stable ABI extension modules HOT 4
- `FrameLocalsProxy` is stricter than `dict` about what constitutes a match HOT 13
- lgtm/
- ValueError in importlib.metadata for eggs with files installed outside the site packages
- Given type X = T ... X does not dereference to T HOT 2
- Simplify consumers by adding `*.Queue.iter()` and `*.Queue.iter_nowait()` HOT 2
- queue.SimpleQueue() uses just a list in it's C implementation. deque wouuld be much faster. HOT 5
- email module generates wrong MIME header with quoted-printable encoded extra space with Python 3.12.4 HOT 1
- python syntax paser error, cant run print after a comment HOT 2
- importlib.reload not updated when only change a little bit code layout
- `__del__` documentation does not mention `weakref`
- cannot create a UNC path drive from parts HOT 5
- multipart/related mail generated with EmailMessage() class lacks mandatory MIME-Version header HOT 1
- Simplify consumers with iteration over `*.Queue` HOT 4
- math.log handles int but not 3rd party integer types HOT 8
- Add subprocess.shell(cmd) function: similar to os.system(), but use subprocess HOT 5
- Add UOp Paircounts to JIT when Built with PyStats
- Parser compares `int` to `Py_ssize_t` poorly HOT 3
- test_python_executable failure on macOS 12.7.5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.