Skip to content

Commit

Permalink
testlib: refactored clean_dir default arguments
Browse files Browse the repository at this point in the history
* Adds: new default argument to `clean_dir` method is the generated DB folder from `scrapy-crawl-once` plugin.

Addresses inspirehep#161

Signed-off-by: Spiros Delviniotis <[email protected]>
  • Loading branch information
spirosdelviniotis authored and david-caro committed Sep 4, 2017
1 parent 6897d81 commit 1a95836
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions hepcrawl/testlib/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ def expected_json_results_from_file(*path_chunks, **kwargs):

return expected_data


def clean_dir(path):
def clean_dir(path=os.path.join(os.getcwd(), '.scrapy')):
"""
Deletes all contained files of given target directory path.
Args:
path: Absolute path of target directory to be cleaned.
path(str): path of directory to be deleted. Default path is the produced DB per spider that
stores the requested urls.
Example:
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/arxiv/test_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from __future__ import absolute_import, division, print_function

import os
from time import sleep
import pytest

Expand Down Expand Up @@ -53,7 +52,7 @@ def set_up_local_environment():
}
}

clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))
clean_dir()


@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/wsp/test_wsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def set_up_ftp_environment():
)

# The test must wait until the docker environment is up (takes about 10 seconds).
sleep(7)
sleep(10)

yield {
'CRAWLER_HOST_URL': 'http://scrapyd:6800',
Expand All @@ -55,7 +55,7 @@ def set_up_ftp_environment():
}
}

clean_dir(path='/tmp/WSP/')
clean_dir()
clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))


Expand All @@ -81,7 +81,7 @@ def set_up_local_environment():


def remove_generated_files(package_location):
clean_dir(path='/tmp/WSP/')
clean_dir()
clean_dir(path=os.path.join(os.getcwd(), '.scrapy'))

_, dirs, files = next(os.walk(package_location))
Expand Down

0 comments on commit 1a95836

Please sign in to comment.