Avoid “__init__.py” files in test directories.

As recommended here:

	https://pytest.org/latest/goodpractises.html
This commit is contained in:
Jakub Roztocil 2014-04-28 11:29:41 +02:00
parent faec00fd99
commit 2aa53e4be3
16 changed files with 29 additions and 27 deletions

View File

@ -1,4 +1,5 @@
import os """Test data"""
from os import path
import codecs import codecs
@ -11,10 +12,10 @@ def patharg(path):
return path.replace('\\', '\\\\\\') return path.replace('\\', '\\\\\\')
FIXTURES_ROOT = os.path.abspath(os.path.dirname(__file__)) FIXTURES_ROOT = path.join(path.abspath(path.dirname(__file__)), 'fixtures')
FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.txt') FILE_PATH = path.join(FIXTURES_ROOT, 'test.txt')
JSON_FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.json') JSON_FILE_PATH = path.join(FIXTURES_ROOT, 'test.json')
BIN_FILE_PATH = os.path.join(FIXTURES_ROOT, 'test.bin') BIN_FILE_PATH = path.join(FIXTURES_ROOT, 'test.bin')
FILE_PATH_ARG = patharg(FILE_PATH) FILE_PATH_ARG = patharg(FILE_PATH)
@ -37,3 +38,4 @@ with open(BIN_FILE_PATH, 'rb') as f:
BIN_FILE_CONTENT = f.read() BIN_FILE_CONTENT = f.read()
UNICODE = FILE_CONTENT UNICODE = FILE_CONTENT

View File

@ -2,7 +2,7 @@
import requests import requests
import pytest import pytest
from tests import http, httpbin, HTTP_OK from utils import http, httpbin, HTTP_OK
import httpie.input import httpie.input

View File

@ -1,8 +1,8 @@
"""Tests for dealing with binary request and response data.""" """Tests for dealing with binary request and response data."""
from httpie.compat import urlopen from httpie.compat import urlopen
from httpie.output.streams import BINARY_SUPPRESSED_NOTICE from httpie.output.streams import BINARY_SUPPRESSED_NOTICE
from tests import TestEnvironment, http, httpbin from utils import TestEnvironment, http, httpbin
from tests.fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG from fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG
class TestBinaryRequestData: class TestBinaryRequestData:

View File

@ -9,8 +9,8 @@ from httpie import input
from httpie.input import KeyValue, KeyValueArgType from httpie.input import KeyValue, KeyValueArgType
from httpie import ExitStatus from httpie import ExitStatus
from httpie.cli import parser from httpie.cli import parser
from tests import TestEnvironment, http, httpbin, HTTP_OK from utils import TestEnvironment, http, httpbin, HTTP_OK
from tests.fixtures import ( from fixtures import (
FILE_PATH_ARG, JSON_FILE_PATH_ARG, FILE_PATH_ARG, JSON_FILE_PATH_ARG,
JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH JSON_FILE_CONTENT, FILE_CONTENT, FILE_PATH
) )

View File

@ -2,8 +2,8 @@
Tests for the provided defaults regarding HTTP method, and --json vs. --form. Tests for the provided defaults regarding HTTP method, and --json vs. --form.
""" """
from tests import TestEnvironment, http, httpbin, HTTP_OK from utils import TestEnvironment, http, httpbin, HTTP_OK
from tests.fixtures import FILE_PATH from fixtures import FILE_PATH
class TestImplicitHTTPMethod: class TestImplicitHTTPMethod:

View File

@ -4,7 +4,7 @@ import subprocess
import pytest import pytest
from tests import TESTS_ROOT from utils import TESTS_ROOT
def has_docutils(): def has_docutils():

View File

@ -9,7 +9,7 @@ from httpie.downloads import (
parse_content_range, filename_from_content_disposition, filename_from_url, parse_content_range, filename_from_content_disposition, filename_from_url,
get_unique_filename, ContentRangeError, Download, get_unique_filename, ContentRangeError, Download,
) )
from tests import httpbin, http, TestEnvironment from utils import httpbin, http, TestEnvironment
class Response(object): class Response(object):

View File

@ -2,7 +2,7 @@ import requests
import pytest import pytest
from httpie import ExitStatus from httpie import ExitStatus
from tests import TestEnvironment, http, httpbin, HTTP_OK from utils import TestEnvironment, http, httpbin, HTTP_OK
class TestExitStatus: class TestExitStatus:

View File

@ -1,6 +1,6 @@
"""High-level tests.""" """High-level tests."""
from tests import TestEnvironment, http, httpbin, HTTP_OK from utils import TestEnvironment, http, httpbin, HTTP_OK
from tests.fixtures import FILE_PATH, FILE_CONTENT from fixtures import FILE_PATH, FILE_CONTENT
import httpie import httpie

View File

@ -2,7 +2,7 @@ import pytest
from httpie import ExitStatus from httpie import ExitStatus
from httpie.output.processors.colors import get_lexer 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

View File

@ -3,8 +3,8 @@ import os
import shutil import shutil
from httpie.plugins.builtin import HTTPBasicAuth from httpie.plugins.builtin import HTTPBasicAuth
from tests import TestEnvironment, mk_config_dir, http, httpbin, HTTP_OK from utils import TestEnvironment, mk_config_dir, http, httpbin, HTTP_OK
from tests.fixtures import UNICODE from fixtures import UNICODE
class SessionTestBase(object): class SessionTestBase(object):

View File

@ -2,8 +2,8 @@ import pytest
from httpie.compat import is_windows from httpie.compat import is_windows
from httpie.output.streams import BINARY_SUPPRESSED_NOTICE from httpie.output.streams import BINARY_SUPPRESSED_NOTICE
from tests import http, httpbin, TestEnvironment from utils import http, httpbin, TestEnvironment
from tests.fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH from fixtures import BIN_FILE_CONTENT, BIN_FILE_PATH
class TestStream: class TestStream:

View File

@ -3,8 +3,8 @@
Various unicode handling related tests. Various unicode handling related tests.
""" """
from tests import http, httpbin, HTTP_OK from utils import http, httpbin, HTTP_OK
from tests.fixtures import UNICODE from fixtures import UNICODE
class TestUnicode: class TestUnicode:

View File

@ -3,8 +3,8 @@ import os
import pytest import pytest
from httpie.input import ParseError from httpie.input import ParseError
from tests import TestEnvironment, http, httpbin, HTTP_OK from utils import TestEnvironment, http, httpbin, HTTP_OK
from tests.fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
class TestMultipartFormDataFileUpload: class TestMultipartFormDataFileUpload:

View File

@ -4,7 +4,7 @@ import tempfile
import pytest import pytest
from httpie.context import Environment from httpie.context import Environment
from tests import TestEnvironment, http, httpbin from utils import TestEnvironment, http, httpbin
from httpie.compat import is_windows from httpie.compat import is_windows