question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inverse versions of `python_files` and `python_functions`.

See original GitHub issue

Suppose my tests are in a well-marked file such as test_queue.py. It doesn’t make sense to name tests in the form test_queue_starts_empty(), test_queue_size_increases_after_push(), and so forth, because I know they’re tests. I can set python_functions = * to drop the test_ prefix, which is nice until I end up with a passing fancy to extract something out of a test to a utility function without turning it into a fixture, then suddenly my utility function is run as a test.

That’s not the worst thing ever, because if my util function doesn’t do any asserting it won’t cause a CI failure or what have you, but it still counts as +1 test, which isn’t ideal.

Were I able to instead set python_ignore_functions = _*, that would be lovely.

The exact same argument applies to python_files - let’s say all of my tests are under tests/ - they have no need to be named test_queue.py, test_stack.py, etc., because I know they’re test modules by dint of being in the directory where tests go. Again, python_files = * is great, until I end up with a util function I want to reuse across multiple files (yet somehow still not wanting to turn it into a fixture), and now it’s being picked up as a test module.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Aug 23, 2022

I reject the proposal based on the notion that it adds too many footguns

There has to be a ballance between enabling behaviour and feature creep

In particular the existence of certain options does never have to imply the existence of inverse

1reaction
nicoddemuscommented, Aug 23, 2022

Hi @Asday,

Thanks for the write up!

Being explicit about test functions also has advantages: it is convenient to be able to search for test_ to find test functions, new contributors to a project immediately recognize def test_ as test functions, etc. For this reason I’m -1 on the idea, feels like feature bloat to the core.

But I’m sure it should be possible to implement that as a separate plugin, if you feel strongly about this feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python reversed() function - ThePythonGuru.com
The reversed() function allows us to process the items in a sequence in reverse order. It accepts a sequence and returns an iterator....
Read more >
Python reversed() function - w3resource
The reversed() function is used to get a reverse iterator. Version: (Python 3.2.5). Syntax: reversed(seq). Parameter: ...
Read more >
Python reversed() (With Examples) - Programiz
Python reversed ()​​ The reversed() method computes the reverse of a given sequence object and returns it in the form of a list....
Read more >
Inverse Function Problems Automated with Python, Markdown ...
In this video I show you how I create 100 inverse function problems of the form f(x) = ax + b, where a...
Read more >
Python reversed() function - GeeksforGeeks
Python reversed () method returns an iterator that accesses the given sequence in the reverse order. Python reversed() Syntax. reversed(sequ) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found