3 ms·
I get that pytest has features that unittest does not, but how is scanning for test files in a directory considered appropriate for what is called a high securi
by bgwalter 1y ago
I get that pytest has features that unittest does not, but how is scanning for test files in a directory considered appropriate for what is called a high security application in the article?
For high security applications the test suite should be boring and straightforward. pytest is full of magic, which makes it so slow.
Python in general has become so complex, informally specified and bug ridden that it only survives because of AI while silencing critics in their bubble.
The complexity includes PSF development processes, which lead to:
https://www.schneier.com/blog/archives/2024/08/leaked-github-python-token.html https://www.schneier.com/blog/archives/2024/08/leaked-github...
- williamdclt 1y ago> it only survives because of AI I don't disagree that it's "complex, informally specified" (idk about bug ridden or silencing critics), but it's just silly to say it only survives because of AI. It was a top-used language before AI got big for web development, data science and all sorts of scientific analysis, and these haven't gone away: I don't expect Python lost much ground in these fields, if any.
- bgwalter 1y agoDropbox moved parts from Python to Golang already in 2014. Google fired the Python team last year and I hear that it does not use Python for new code. Instagram is kept afloat by gigantic hacks. The scientific ecosystem was always there, but relied on heavy marketing to academics, who (sadly) in turn indoctrinate new students to use Python as a first language. I did forget about sysadmin use cases in Linux distributions, but they could be easily replaced by even Perl, as leaner BSD distributions already do.
- guappa 1y agoYou'd be right if go wasn't an awful language designed by someone who clearly failed their compiler class at university.
- deleted 1y ago[deleted]
- selfselfgo 1y ago[dead]
- westurner 1y agostrace is one way to determine how many stat calls a process makes. Developers avoid refactoring costs by using dependency inversion, fixtures and functional test assertions without OO in the tests, too. Pytest collection could be made faster with ripgrep and does it even need AST? A thread here mentions how it's possible to prepare a list of .py test files containing functions that start with "test_" to pass to the `pytest -k` option; for example with ripgrep. One day I did too much work refactoring tests to minimize maintenance burden and wrote myself a functional test runner that captures AssertionErrors and outputs with stdlib only. It's possible to use unittest.TestCase() assertion methods functionally: assert 0 == 1 # AssertionError import unittest test = unittest.TestCase() test.assertEqual(0, 1) # AssertionError: 0 != 1 unittest.TestCase assertion methods have default error messages, but the `assert` keyword does not. In order to support one file stdlib-only modules, I have mocked pytest.mark.parametrize a number of times. chmp/ipytest is one way to transform `assert a == b` to `assertEqual(a,b)` like Pytest in Jupyter notebooks. Python continues to top language use and popularity benchmarks. Python is not a formally specified language, mostly does not have constant time operations (or documented complexity in docstring attrs), has a stackless variant, supported asynchronous coroutines natively before C++, now has some tail-call optimization in 3.14, now has nogil mode, and is GPU accelerated in many different ways. How best could they scan for API tokens committed to public repos?
- woodruffw 1y agopytest's magic is not itself a significant overhead factor. All test suite systems need to perform a similar type of collection; unittest does the exact same thing via `unittest.main()`.
- zahlman 1y agoCritics of Python don't get "silenced in their bubble" generally, just ignored. Critics of the PSF, well, that's another story. As for complexity, it's not so much that new features are added, but that people are using Python in larger systems, and demanding things to help manage the complexity (that end up adding more complexity of their own). The Zen of Python is forgotten - and that's largely on the users. pytest is full of magic, but at least it uses that magic to present a pleasant UI. Certainly better than unittest's JUnit-inspired design. But it'd be that much nicer to have something that gets there directly rather than wrapping the bad stuff, and which honours "simple is better than complex" and "explicit is better than implicit" (test discovery, but also fixtures).
- bgwalter 1y ago> Critics of Python don't get "silenced in their bubble" generally, just ignored. I disagree. The public bans are just the tip of the iceberg. Here is a relatively undocumented one: https://lwn.net/Articles/1003436/ https://lwn.net/Articles/1003436/ It is typical for a variety of reasons. Someone complains about breakage and is banned. Later, when the right people complain about the same issue, the breakage is reverted. The same pattern happens over and over. The SC and the PSF are irresponsible, incompetent and malicious.