From 2aa53e4be39dcb9409884d9f13c3cc235dff9e42 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Mon, 28 Apr 2014 11:29:41 +0200 Subject: [PATCH] =?UTF-8?q?Avoid=20=E2=80=9C=5F=5Finit=5F=5F.py=E2=80=9D?= =?UTF-8?q?=20files=20in=20test=20directories.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As recommended here: https://pytest.org/latest/goodpractises.html --- tests/{fixtures/__init__.py => fixtures.py} | 12 +++++++----- tests/test_auth.py | 2 +- tests/test_binary.py | 4 ++-- tests/test_cli.py | 4 ++-- tests/test_defaults.py | 4 ++-- tests/test_docs.py | 2 +- tests/test_downloads.py | 2 +- tests/test_exit_status.py | 2 +- tests/test_httpie.py | 4 ++-- tests/test_output.py | 2 +- tests/test_sessions.py | 4 ++-- tests/test_stream.py | 4 ++-- tests/test_unicode.py | 4 ++-- tests/test_uploads.py | 4 ++-- tests/test_windows.py | 2 +- tests/{__init__.py => utils.py} | 0 16 files changed, 29 insertions(+), 27 deletions(-) rename tests/{fixtures/__init__.py => fixtures.py} (73%) rename tests/{__init__.py => utils.py} (100%) diff --git a/tests/fixtures/__init__.py b/tests/fixtures.py similarity index 73% rename from tests/fixtures/__init__.py rename to tests/fixtures.py index de309c9d..c7b769e6 100644 --- a/tests/fixtures/__init__.py +++ b/tests/fixtures.py @@ -1,4 +1,5 @@ -import os +"""Test data""" +from os import path import codecs @@ -11,10 +12,10 @@ def patharg(path): return path.replace('\\', '\\\\\\') -FIXTURES_ROOT = os.path.abspath(os.path.dirname(__file__)) -FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.txt') -JSON_FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.json') -BIN_FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.bin') +FIXTURES_ROOT = path.join(path.abspath(path.dirname(__file__)), 'fixtures') +FILE_PATH = path.join(FIXTURES_ROOT, 'test.txt') +JSON_FILE_PATH = path.join(FIXTURES_ROOT, 'test.json') +BIN_FILE_PATH = path.join(FIXTURES_ROOT, 'test.bin') FILE_PATH_ARG = patharg(FILE_PATH) @@ -37,3 +38,4 @@ with open(BIN_FILE_PATH, 'rb') as f: BIN_FILE_CONTENT = f.read() UNICODE = FILE_CONTENT + diff --git a/tests/test_auth.py b/tests/test_auth.py index a0c249cd..1977a064 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -2,7 +2,7 @@ import requests import pytest -from tests import http, httpbin, HTTP_OK +from utils import http, httpbin, HTTP_OK import httpie.input diff --git a/tests/test_binary.py b/tests/test_binary.py index 683b2143..7a1bd062 100644 --- a/tests/test_binary.py +++ b/tests/test_binary.py @@ -1,8 +1,8 @@ """Tests for dealing with binary request and response data.""" from httpie.compat import urlopen from httpie.output.streams import BINARY_SUPPRESSED_NOTICE -from tests import TestEnvironment, http, httpbin -from tests.fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG +from utils import TestEnvironment, http, httpbin +from fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG class TestBinaryRequestData: diff --git a/tests/test_cli.py b/tests/test_cli.py index cd4ea019..c19fcb29 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -9,8 +9,8 @@ from httpie import input from httpie.input import KeyValue, KeyValueArgType from httpie import ExitStatus from httpie.cli import parser -from tests import TestEnvironment, http, httpbin, HTTP_OK -from tests.fixtures import ( +from utils import TestEnvironment, http, httpbin, HTTP_OK +from fixtures import ( FILE_PATH_ARG, JSON_FILE_PATH_ARG, JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH ) diff --git a/tests/test_defaults.py b/tests/test_defaults.py index 2e64097e..0999a264 100644 --- a/tests/test_defaults.py +++ b/tests/test_defaults.py @@ -2,8 +2,8 @@ Tests for the provided defaults regarding HTTP method, and --json vs. --form. """ -from tests import TestEnvironment, http, httpbin, HTTP_OK -from tests.fixtures import FILE_PATH +from utils import TestEnvironment, http, httpbin, HTTP_OK +from fixtures import FILE_PATH class TestImplicitHTTPMethod: diff --git a/tests/test_docs.py b/tests/test_docs.py index ab63a05d..ed2ad1e9 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -4,7 +4,7 @@ import subprocess import pytest -from tests import TESTS_ROOT +from utils import TESTS_ROOT def has_docutils(): diff --git a/tests/test_downloads.py b/tests/test_downloads.py index cea9074d..ce722606 100644 --- a/tests/test_downloads.py +++ b/tests/test_downloads.py @@ -9,7 +9,7 @@ from httpie.downloads import ( parse_content_range, filename_from_content_disposition, filename_from_url, get_unique_filename, ContentRangeError, Download, ) -from tests import httpbin, http, TestEnvironment +from utils import httpbin, http, TestEnvironment class Response(object): diff --git a/tests/test_exit_status.py b/tests/test_exit_status.py index 528cc3e0..558ecc52 100644 --- a/tests/test_exit_status.py +++ b/tests/test_exit_status.py @@ -2,7 +2,7 @@ import requests import pytest from httpie import ExitStatus -from tests import TestEnvironment, http, httpbin, HTTP_OK +from utils import TestEnvironment, http, httpbin, HTTP_OK class TestExitStatus: diff --git a/tests/test_httpie.py b/tests/test_httpie.py index c8b1ec89..824a94b2 100644 --- a/tests/test_httpie.py +++ b/tests/test_httpie.py @@ -1,6 +1,6 @@ """High-level tests.""" -from tests import TestEnvironment, http, httpbin, HTTP_OK -from tests.fixtures import FILE_PATH, FILE_CONTENT +from utils import TestEnvironment, http, httpbin, HTTP_OK +from fixtures import FILE_PATH, FILE_CONTENT import httpie diff --git a/tests/test_output.py b/tests/test_output.py index a6efb550..edb5a26c 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -2,7 +2,7 @@ import pytest from httpie import ExitStatus from httpie.output.processors.colors import get_lexer -from tests import TestEnvironment, http, httpbin, HTTP_OK, COLOR, CRLF +from utils import TestEnvironment, http, httpbin, HTTP_OK, COLOR, CRLF diff --git a/tests/test_sessions.py b/tests/test_sessions.py index f9ca700f..77ab6ca2 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -3,8 +3,8 @@ import os import shutil from httpie.plugins.builtin import HTTPBasicAuth -from tests import TestEnvironment, mk_config_dir, http, httpbin, HTTP_OK -from tests.fixtures import UNICODE +from utils import TestEnvironment, mk_config_dir, http, httpbin, HTTP_OK +from fixtures import UNICODE class SessionTestBase(object): diff --git a/tests/test_stream.py b/tests/test_stream.py index febc2676..d21e98ef 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -2,8 +2,8 @@ import pytest from httpie.compat import is_windows from httpie.output.streams import BINARY_SUPPRESSED_NOTICE -from tests import http, httpbin, TestEnvironment -from tests.fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH +from utils import http, httpbin, TestEnvironment +from fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH class TestStream: diff --git a/tests/test_unicode.py b/tests/test_unicode.py index 3e0803a3..fe8743b1 100644 --- a/tests/test_unicode.py +++ b/tests/test_unicode.py @@ -3,8 +3,8 @@ Various unicode handling related tests. """ -from tests import http, httpbin, HTTP_OK -from tests.fixtures import UNICODE +from utils import http, httpbin, HTTP_OK +from fixtures import UNICODE class TestUnicode: diff --git a/tests/test_uploads.py b/tests/test_uploads.py index 75598dcb..073b98c9 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -3,8 +3,8 @@ import os import pytest from httpie.input import ParseError -from tests import TestEnvironment, http, httpbin, HTTP_OK -from tests.fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT +from utils import TestEnvironment, http, httpbin, HTTP_OK +from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT class TestMultipartFormDataFileUpload: diff --git a/tests/test_windows.py b/tests/test_windows.py index 6730e3bf..ad15fe52 100644 --- a/tests/test_windows.py +++ b/tests/test_windows.py @@ -4,7 +4,7 @@ import tempfile import pytest from httpie.context import Environment -from tests import TestEnvironment, http, httpbin +from utils import TestEnvironment, http, httpbin from httpie.compat import is_windows diff --git a/tests/__init__.py b/tests/utils.py similarity index 100% rename from tests/__init__.py rename to tests/utils.py