Skip to content

Commit

Permalink
Move shared test code from ext/ to tests/ (#559)
Browse files Browse the repository at this point in the history
opentelemetry-ext-testutil is a package with shared test classes used by ext packages (right now only opentelemetry-ext-flask). We don't release this package, just import it in other tests.

Right now, on each release, we build everything in ext/. This means whoever does the release has to remember to exclude this package when they push the others to PyPI.

This moves the files and package:

Move files ext/opentelemetry-ext-testutil -> tests/util
Move package opentelemetry.ext.testutil -> opentelemetry.test
This makes maintainers' lives easier, but it does mean that other packages that use testutils will have to install install the opentelemetry.test package from source. But this is already the case since we don't publish opentelemetry-ext-testutil.

we move shared test code back into the main repo until we move a package that depends on it into a separate repo, at which point we'll have to put this code in its own top-level package.
  • Loading branch information
c24t authored Apr 15, 2020
1 parent 380ce95 commit 7d11cf1
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion ext/opentelemetry-ext-flask/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ install_requires =

[options.extras_require]
test =
opentelemetry-ext-testutil == 0.7.dev0
flask~=1.0
opentelemetry-test == 0.7.dev0

[options.packages.find]
where = src
7 changes: 2 additions & 5 deletions ext/opentelemetry-ext-flask/tests/test_flask_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from werkzeug.wrappers import BaseResponse

from opentelemetry import trace as trace_api
from opentelemetry.ext.testutil.wsgitestutil import WsgiTestBase
from opentelemetry.test.wsgitestutil import WsgiTestBase


def expected_attributes(override_attributes):
Expand Down Expand Up @@ -78,10 +78,7 @@ def assert_environ():

def test_simple(self):
expected_attrs = expected_attributes(
{
"http.target": "/hello/123",
"http.route": "/hello/<int:helloid>",
}
{"http.target": "/hello/123", "http.route": "/hello/<int:helloid>"}
)
resp = self.client.get("/hello/123")
self.assertEqual(200, resp.status_code)
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-wsgi/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ install_requires =

[options.extras_require]
test =
opentelemetry-ext-testutil == 0.7.dev0
opentelemetry-test == 0.7.dev0

[options.packages.find]
where = src
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-wsgi/tests/test_wsgi_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import opentelemetry.ext.wsgi as otel_wsgi
from opentelemetry import trace as trace_api
from opentelemetry.ext.testutil.wsgitestutil import WsgiTestBase
from opentelemetry.test.wsgitestutil import WsgiTestBase


class Response:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

[metadata]
name = opentelemetry-ext-testutil
name = opentelemetry-test
description = Test utilities for OpenTelemetry unit tests
author = OpenTelemetry Authors
author_email = cncf-opentelemetry-contributors@lists.cncf.io
url = https://github.com/open-telemetry/opentelemetry-python/ext/opentelemetry-ext-testutil
url = https://github.com/open-telemetry/opentelemetry-python/tests/util
platforms = any
license = Apache-2.0
classifiers =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(
BASE_DIR, "src", "opentelemetry", "ext", "testutil", "version.py"
BASE_DIR, "src", "opentelemetry", "test", "version.py"
)
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ commands_pre =
ext: pip install {toxinidir}/opentelemetry-api
grpc: pip install {toxinidir}/ext/opentelemetry-ext-grpc
grpc: pip install {toxinidir}/opentelemetry-sdk
wsgi,flask: pip install {toxinidir}/ext/opentelemetry-ext-testutil
wsgi,flask: pip install {toxinidir}/tests/util
wsgi,flask: pip install {toxinidir}/ext/opentelemetry-ext-wsgi
wsgi,flask: pip install {toxinidir}/opentelemetry-sdk
flask: pip install {toxinidir}/opentelemetry-auto-instrumentation
Expand Down

0 comments on commit 7d11cf1

Please sign in to comment.