Skip to content

Commit

Permalink
Move test utility modules into test/utils/
Browse files Browse the repository at this point in the history
This patch moves all test utility modules into `test/utils/` and the
tests for these modules into `test/utils/test/`.

This is to make test utilities more organized and in preperation for
adding more test utilities related to test suites.
  • Loading branch information
aucampia committed May 2, 2022
1 parent 39e0d4b commit e443404
Show file tree
Hide file tree
Showing 30 changed files with 39 additions and 36 deletions.
4 changes: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from rdflib import Graph

from .data import TEST_DATA_DIR
from .earl import EarlReporter
from .utils.earl import EarlReporter

pytest_plugins = [EarlReporter.__module__]

# This is here so that asserts from these modules are formatted for human
# readibility.
pytest.register_assert_rewrite("test.testutils")
pytest.register_assert_rewrite("test.utils")


@pytest.fixture(scope="session")
Expand Down
2 changes: 1 addition & 1 deletion test/test_graph/test_canonicalization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from collections import Counter
from io import StringIO
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import Set, Tuple

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_graph/test_diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import Set, Tuple
from unittest.case import expectedFailure

Expand Down
2 changes: 1 addition & 1 deletion test/test_graph/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from tempfile import mkdtemp, mkstemp
from test.data import TEST_DATA_DIR, bob, cheese, hates, likes, michel, pizza, tarek
from test.testutils import GraphHelper, get_unique_plugin_names
from test.utils import GraphHelper, get_unique_plugin_names
from typing import Callable, Optional, Set
from urllib.error import HTTPError, URLError

Expand Down
7 changes: 1 addition & 6 deletions test/test_graph/test_graph_http.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import unittest
from http.server import BaseHTTPRequestHandler
from test.testutils import (
GraphHelper,
MockHTTPResponse,
SimpleHTTPMock,
ctx_http_server,
)
from test.utils import GraphHelper, MockHTTPResponse, SimpleHTTPMock, ctx_http_server
from urllib.error import HTTPError

from rdflib import Graph, Namespace
Expand Down
2 changes: 1 addition & 1 deletion test/test_graph/test_skolemization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import re
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import Pattern, Union

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_graph/test_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass, field
from pathlib import Path, PurePath
from test.data import TEST_DATA_DIR
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import (
ClassVar,
Collection,
Expand Down
2 changes: 1 addition & 1 deletion test/test_issues/test_issue274.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.testutils import eq_
from test.utils import eq_
from unittest import TestCase

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_parsers/test_nquads_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from test.data import TEST_DATA_DIR
from test.manifest import RDFT, RDFTest, read_manifest
from test.utils.manifest import RDFT, RDFTest, read_manifest
from typing import Callable, Dict

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_parsers/test_nt_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from test import TEST_DIR
from test.data import TEST_DATA_DIR
from test.manifest import RDFT, RDFTest, read_manifest
from test.utils.manifest import RDFT, RDFTest, read_manifest
from typing import Callable, Dict

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_parsers/test_trig_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from test.data import TEST_DATA_DIR
from test.manifest import RDFT, RDFTest, read_manifest
from test.utils.manifest import RDFT, RDFTest, read_manifest
from typing import Callable, Dict

import pytest
Expand Down
4 changes: 2 additions & 2 deletions test/test_parsers/test_turtle_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import os
from pathlib import Path
from test.data import TEST_DATA_DIR
from test.manifest import RDFT, RDFTest, read_manifest
from test.testutils import file_uri_to_path
from test.utils import file_uri_to_path
from test.utils.manifest import RDFT, RDFTest, read_manifest
from typing import Callable, Dict, Set

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from json.decoder import JSONDecodeError
from pathlib import Path
from test.data import TEST_DATA_DIR
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import Callable, Collection, Iterable, List, Optional, Set, Tuple, Union
from xml.sax import SAXParseException

Expand Down
2 changes: 1 addition & 1 deletion test/test_serializers/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
from pathlib import Path
from test.testutils import GraphHelper
from test.utils import GraphHelper
from typing import Tuple, cast

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_sparql/test_construct_bindings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from test.testutils import eq_
from test.utils import eq_

from rdflib import BNode, Graph, Literal, URIRef
from rdflib.compare import isomorphic
Expand Down
2 changes: 1 addition & 1 deletion test/test_sparql/test_datetime_processing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io
from pprint import pprint
from test.testutils import eq_
from test.utils import eq_

import rdflib
from rdflib import XSD, BNode, Graph, Literal, URIRef
Expand Down
4 changes: 2 additions & 2 deletions test/test_sparql/test_dawg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# http://www.w3.org/2009/sparql/docs/tests/data-sparql11/
# syntax-update-2/manifest#syntax-update-other-01
from test import TEST_DIR
from test.manifest import MF, UP, RDFTest, ResultType, read_manifest
from test.testutils import file_uri_to_path
from test.utils import file_uri_to_path
from test.utils.manifest import MF, UP, RDFTest, ResultType, read_manifest

import pytest

Expand Down
2 changes: 1 addition & 1 deletion test/test_sparql/test_expressions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import partial
from test.testutils import eq_ as eq
from test.utils import eq_ as eq

import rdflib.plugins.sparql.parser as p
from rdflib import Literal, Variable
Expand Down
2 changes: 1 addition & 1 deletion test/test_sparql/test_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test import helper
from test.utils import helper

from rdflib import Graph, Literal, URIRef, Variable
from rdflib.compare import isomorphic
Expand Down
2 changes: 1 addition & 1 deletion test/test_sparql/test_sparql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from test.testutils import eq_
from test.utils import eq_
from typing import Any, Callable, Mapping, Sequence, Type

import pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_store/test_namespace_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from dataclasses import dataclass, field
from pathlib import Path
from test.testutils import pytest_mark_filter
from test.utils import pytest_mark_filter
from typing import Any, Callable, Dict, Set, Union

import pytest
Expand Down
3 changes: 1 addition & 2 deletions test/test_store/test_store_sparqlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import socket
import unittest
from http.server import BaseHTTPRequestHandler, HTTPServer
from test import helper
from test.testutils import MockHTTPResponse, ServedSimpleHTTPMock
from test.utils import MockHTTPResponse, ServedSimpleHTTPMock, helper
from threading import Thread
from typing import Callable, ClassVar, Type
from unittest.mock import patch
Expand Down
2 changes: 1 addition & 1 deletion test/test_store/test_store_sparqlupdatestore_mock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from test.testutils import MockHTTPResponse, ServedSimpleHTTPMock
from test.utils import MockHTTPResponse, ServedSimpleHTTPMock
from typing import ClassVar

from rdflib import Namespace
Expand Down
2 changes: 1 addition & 1 deletion test/test_turtle_quoting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rdflib.plugins.parsers import ntriples
from rdflib.term import Literal, URIRef

from .testutils import GraphHelper
from .utils import GraphHelper

# https://www.w3.org/TR/turtle/#string
string_escape_map = {
Expand Down
7 changes: 7 additions & 0 deletions test/testutils.py → test/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
This module contains test utilities.
The tests for test utilities should be placed inside `test.utils.test`
(``test/utils/tests/``).
"""

from __future__ import print_function

import datetime
Expand Down
2 changes: 1 addition & 1 deletion test/earl.py → test/utils/earl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from datetime import datetime
from pathlib import Path
from test.manifest import RDFT
from test.utils.manifest import RDFT
from typing import TYPE_CHECKING, Generator, Optional, Tuple, cast

import pytest
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions test/utils/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
This module contains tests for test utility modules inside `test.utils` (i.e. ``test/utils/``).
"""
3 changes: 1 addition & 2 deletions test/test_testutils.py → test/utils/test/test_testutils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import os
from dataclasses import dataclass
from pathlib import PurePosixPath, PureWindowsPath
from test.utils import GraphHelper, file_uri_to_path
from typing import Optional

import pytest

from rdflib.graph import ConjunctiveGraph, Graph
from rdflib.term import URIRef

from .testutils import GraphHelper, file_uri_to_path


def check(
file_uri: str,
Expand Down

0 comments on commit e443404

Please sign in to comment.