Skip to content

Commit

Permalink
unit tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn committed Jul 10, 2024
1 parent 50e5547 commit b29b4e6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'inspire-utils~=3.0,>=3.0.0',
# newer scrapy is incompatible with old scrapyd
'Scrapy~=1.6,<1.7.0',
'parsel<=1.8.0',
'scrapy-crawl-once~=0.1,>=0.1.1',
'scrapy-sentry~=0.0,>=0.8.0',
# TODO: unpin once they support wheel building again, needed for Python 3
Expand Down Expand Up @@ -62,7 +63,7 @@
'freezegun>=0.3.9',
'isort==4.2.2',
'mock~=2.0,>=2.0.0',
'pytest>=2.8.0',
'pytest>=2.8.0, <8.0.0',
'pytest-cov>=2.1.0',
'pytest-pep8>=1.0.6',
'requests-mock>=1.3.0',
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/test_desy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from __future__ import absolute_import, division, print_function

import os

import sys
import mock
import pytest
from deepdiff import DeepDiff
Expand Down Expand Up @@ -106,6 +106,8 @@ def override_generated_fields(record):
]
)
def test_pipeline(generated_records, expected_records):
if sys.version_info[0] >= 3:
unicode = str
clean_generated_records = [
override_generated_fields(generated_record)
for generated_record in generated_records
Expand All @@ -126,6 +128,10 @@ def test_invalid_jsonll():
response.meta = {"s3_subdirectory": 'invalid_record'}

result = list(spider.parse(response))
assert result[0].exception.startswith('ValueError')
exception = result[0].exception
if exception.startswith('ValueError') or exception.startswith('JSONDecodeError'):
assert True
else:
assert False
assert result[0].traceback is not None
assert result[0].source_data == "This is not actually JSONL"
7 changes: 5 additions & 2 deletions tests/unit/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# more details.

import logging

import sys
from scrapy.utils.project import get_project_settings
from scrapy.utils.log import (configure_logging, logger)

Expand All @@ -21,4 +21,7 @@ def test_log_settings():

configure_logging(settings=settings)
assert any(isinstance(handler, logging.StreamHandler) for handler in logger.root.handlers)
assert not any(isinstance(handler, logging.FileHandler) for handler in logger.root.handlers)
if sys.version_info[0] >= 3:
assert any(isinstance(handler, logging.FileHandler) and handler.level == logging.NOTSET for handler in logger.root.handlers)
else:
assert not any(isinstance(handler, logging.FileHandler) for handler in logger.root.handlers)

0 comments on commit b29b4e6

Please sign in to comment.