Comments (4)
this is a unfortunate side-effect of ensuring staying debugable
there was no effort yet to provide a api/hook to purge tracebakcs/stacktraces of expensive resources
in this case im considering the array a "resource" as its something that puts possibly large pressure onto the system and ought to be purged if disposable
from pytest.
Hi @RonnyPfannschmidt,
Thanks a lot for the follow-up.
Wondering what was the reason for not providing an api/hook to remove the traceback?
Or the pytest team does not have this in plans at all?
Is it complicated for a beginner to pytest repo like me to try to implement it?
from pytest.
For others who also encounter this issue in their tests,
I found a work-around
import weakref
import numpy as np
import pytest
N = 20_000_000
def get_data(n):
d = np.random.rand(n,100)
return d
def process_data(d):
return np.diff(d)
def test1(data_provider):
d = data_provider.get(N)
process_data(d)
assert False
def test2():
d = get_data(N)
process_data(d)
class DataFlyweight:
def __init__(self):
self._data =[]
def get(self,n):
if n not in self._data:
self._data.append(get_data(n))
return weakref.proxy(self._data[-1])
def clear(self):
self._data.clear()
@pytest.fixture
def data_provider():
data_flyweight = DataFlyweight()
yield data_flyweight
data_flyweight.clear()
Memory does not explode and the second test passed as expected.
from pytest.
Multiple reasons
Initially tracebacks where not attached to exceptions and extracting ex info typically lost a number of locals automatically
Also for most test suites memory intensive variables where no issue
So there was no incentive/pressure to work on a feature with limited win and excessive possible edge cases for a long time
from pytest.
Related Issues (20)
- Support Dark Mode for Pytest Docs Website HOT 5
- Incorrect confcutdir inferred when rootdir is under a symlink directory
- Pytest 8.2.0: "AttributeError: 'VendorImporter' object has no attribute 'find_spec'" HOT 1
- Test collection to broad, walking sideways, causes PermissionError for tests in /tmp subdirs HOT 1
- pytest life cycle (fixture scoped session) HOT 1
- Found a possible security concern HOT 1
- Crashing under a squashfuse_ll read-only mount
- c85fce39b broke importing standard library modules that are "masked"
- Reordering tests with `pytest_collection_modifyitems` hook fails HOT 1
- 8.1.1 removed ability to introspect teardown exceptions in `pytest_fixture_post_finalizer` HOT 2
- Extra info in assertion is truncated even with `-vv` HOT 1
- Error: EACCES: permission denied, scandir .pytest_cache with 8.2.0 HOT 6
- Warn if collection spends >5s traversing a directory without collecting any tests HOT 1
- Test failures on Python 3.13.0b1 HOT 1
- Pytest 8 broke sorting for package-scoped fixtures HOT 1
- Trying to use mypy and pytest with a multiprocessing.Value - unable to use Synchronized as a type HOT 3
- Exit code is 1 when whole file fails, but 0 when individual tests fail HOT 2
- sys.__stdout__.isatty() returns incorrect value for Windows 11
- Populate output xml file after every test on a suite is completed
- 8.2.1: documentation build fails HOT 3
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 pytest.