Comments (5)
Glad you solved your problem.
Next time, I suggest looking inside the warcio tests to see if warcio has a test. In this case, yes, warcio does successfully use pytest in testing. It wouldn't have solved your problem with dash
, but at least you'd know that your environment was where the problem was, and that warcio and pytest do work together.
from warcio.
The following works flawlessly when executed as python test_random.py
# test_random.py
from warcio.capture_http import capture_http
import requests
def test_random():
test_fn = 'random-test-warc.warc.gz'
url = 'http://httpbin.org/get'
with capture_http(test_fn):
response = requests.get(url=url)
if __name__ == '__main__':
test_random()
Seems like it is definitely related to pytest and importing modules in the wrong order. Happy to close this issue, but still would be great to get some guidance on this!
from warcio.
I still cannot figure out why this is happening. I have even added from warcio.capture_http import capture_http # noqa
to every single __init__.py
in the package, but I still cannot run the pytest which produces a WARC file larger than 0 bytes.
Once package is installed, and I run the scraping method in iPython, then I see the expected WARC output. Any ideas what pytest could be doing here to disrupt the import order? Tempted to literally copy capture_http.py
into the package a load capture_http
from there.
from warcio.
This is the package structure if it helps:
.
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── MANIFEST.in
├── README.md
├── playground.ipynb
├── pyproject.toml
├── pytest.ini
├── scrapex
│ ├── __init__.py
│ ├── collectors
│ │ ├── __init__.py
│ │ ├── base.py
│ │ └── batch.py
│ ├── exceptions.py
│ ├── headers
│ │ ├── __init__.py
│ │ ├── data
│ │ │ └── user-agents.txt
│ │ └── utils.py
│ ├── sessions
│ │ ├── __init__.py
│ │ ├── adapters.py
│ │ ├── retry.py
│ │ └── sessions.py
│ └── warc
│ ├── __init__.py
│ ├── base.py
│ ├── index.py
│ ├── readers.py
│ └── writers.py
├── setup.cfg
├── setup.py
└── tests
├── __init__.py
├── integration_tests
│ ├── __init__.py
│ ├── test_collectors_batch.py
│ ├── test_sessions_adapters.py
│ └── test_sessions_sessions.py
└── unit_tests
├── __init__.py
├── resources
│ ├── test-empty-warc-file.warc.gz
│ ├── test-get-html.warc.gz
│ ├── test-get-request.warc.gz
│ ├── test-post-request.warc.gz
│ ├── test-redirect-request.warc.gz
│ └── test-status-codes-get.warc.gz
├── test_collectors_base.py
├── test_collectors_batch.py
├── test_headers_utils.py
├── test_sessions_adapters.py
├── test_sessions_retry.py
├── test_sessions_sessions.py
├── test_warc_base.py
├── test_warc_index.py
├── test_warc_readers.py
└── test_warc_writers.py
from warcio.
RESOLVED - As presumed, nothing to do with warcio
. The issue was pytest
and loaded plugins. In particular, dash
pytest plugin loads the HTTPConnection
prior to the patching. Closing issue for now.
from warcio.
Related Issues (20)
- Record not followed by newline (conversion error) HOT 1
- Warcio does not support replay of sites hosted on NCSA 1.5 HOT 3
- Issues with encoding of http-answers HOT 2
- Documentation: Clarify that capture_http writer with filename has no get_stream methood HOT 3
- warcio.exceptions.ArchiveLoadFailed: Unknown archive format HOT 3
- Empty WARC files when deploying warcio on Airflow HOT 5
- Trying to write to closed file when using `requests.Session`
- Patching WARCs using warcio
- warcio cannot write wet files
- webrecorder fails to open IA warc file on MacOS X Ventura 13.2.1 HOT 2
- wget warc status code? HOT 3
- doc bugs linking to source code files
- "warcio check" incorrectly reporting payload digest failures for non-HTTP WARCs HOT 2
- warcio accepts a bare LF everywhere a CRLF is required by the spec HOT 1
- "warcio check" does not warn of illegal characters in field names or values, including LF HOT 8
- warcio recompress adds WARC-Block-Digest fields to records without one
- warcio recompress adds "WARC-Payload-Digest" to records without understanding them
- DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version HOT 7
- Add test to HTTPS proxies
- py3.12 and setuptools HOT 1
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 warcio.