From fd7b28c05a3405b863a2295e8c88321f55edbec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Fri, 2 Apr 2021 15:13:56 +0200 Subject: [PATCH] misc: pylint fix function-redefined (#52630) --- tests/test_datasource.py | 30 ------------------------------ tests/test_datasource_chrono.py | 31 +++++++++++++++---------------- 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/tests/test_datasource.py b/tests/test_datasource.py index c546bb319..64329e2e3 100644 --- a/tests/test_datasource.py +++ b/tests/test_datasource.py @@ -272,11 +272,6 @@ def test_json_datasource(pub, requests_pub, http_requests): # same with django templated url get_request().datasources_cache = {} - - class JsonUrlPath: - def get_substitution_variables(self): - return {'json_url': 'file://%s' % json_file_path} - pub.substitutions.feed(JsonUrlPath()) datasource = {'type': 'json', 'value': '{{ json_url }}'} assert data_sources.get_items(datasource) == [ @@ -286,11 +281,6 @@ def test_json_datasource(pub, requests_pub, http_requests): # json specified with a variadic url with an erroneous space get_request().datasources_cache = {} - - class JsonUrlPath: - def get_substitution_variables(self): - return {'json_url': 'file://%s' % json_file_path} - pub.substitutions.feed(JsonUrlPath()) datasource = {'type': 'json', 'value': ' [json_url]'} assert data_sources.get_items(datasource) == [ @@ -300,11 +290,6 @@ def test_json_datasource(pub, requests_pub, http_requests): # same with django templated url get_request().datasources_cache = {} - - class JsonUrlPath: - def get_substitution_variables(self): - return {'json_url': 'file://%s' % json_file_path} - pub.substitutions.feed(JsonUrlPath()) datasource = {'type': 'json', 'value': ' {{ json_url }}'} assert data_sources.get_items(datasource) == [ @@ -629,11 +614,6 @@ def test_geojson_datasource(pub, requests_pub, http_requests): # same with django templated url get_request().datasources_cache = {} - - class GeoJSONUrlPath: - def get_substitution_variables(self): - return {'geojson_url': 'file://%s' % geojson_file_path} - pub.substitutions.feed(GeoJSONUrlPath()) datasource = {'type': 'geojson', 'value': '{{ geojson_url }}'} assert data_sources.get_items(datasource) == [ @@ -653,11 +633,6 @@ def test_geojson_datasource(pub, requests_pub, http_requests): # geojson specified with a variadic url with an erroneous space get_request().datasources_cache = {} - - class GeoJSONUrlPath: - def get_substitution_variables(self): - return {'geojson_url': 'file://%s' % geojson_file_path} - pub.substitutions.feed(GeoJSONUrlPath()) datasource = {'type': 'geojson', 'value': ' [geojson_url]'} assert data_sources.get_items(datasource) == [ @@ -677,11 +652,6 @@ def test_geojson_datasource(pub, requests_pub, http_requests): # same with django templated url get_request().datasources_cache = {} - - class GeoJSONUrlPath: - def get_substitution_variables(self): - return {'geojson_url': 'file://%s' % geojson_file_path} - pub.substitutions.feed(GeoJSONUrlPath()) datasource = {'type': 'geojson', 'value': ' {{ geojson_url }}'} assert data_sources.get_items(datasource) == [ diff --git a/tests/test_datasource_chrono.py b/tests/test_datasource_chrono.py index 8d51b2429..7c7390f2e 100644 --- a/tests/test_datasource_chrono.py +++ b/tests/test_datasource_chrono.py @@ -2,11 +2,10 @@ import io import json -import shutil +import os import mock import pytest -from quixote import cleanup from wcs import fields from wcs.data_sources import NamedDataSource, build_agenda_datasources, collect_agenda_data @@ -14,29 +13,29 @@ from wcs.formdef import FormDef from wcs.qommon.http_request import HTTPRequest from wcs.qommon.misc import ConnectionError -from .utilities import create_temporary_pub - - -def setup_module(module): - cleanup() - - global pub - - pub = create_temporary_pub() - pub.cfg['debug'] = {'logger': True} - pub.write_cfg() - pub.set_config() +from .utilities import clean_temporary_pub, create_temporary_pub def teardown_module(module): - shutil.rmtree(pub.APP_DIR) + clean_temporary_pub() @pytest.fixture def pub(request): - req = HTTPRequest(None, {'SERVER_NAME': 'example.net', 'SCRIPT_NAME': ''}) + pub = create_temporary_pub() + req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) pub.set_app_dir(req) pub._set_request(req) + + open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w').write( + ''' +[debug] +logger=true +''' + ) + + pub.load_site_options() + return pub