From 976df5bf96adc16ea8c97e822cf7e773b0525f78 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 17 Oct 2010 15:23:14 -0400 Subject: [PATCH] - the NoseSQLAlchemyPlugin has been moved to a new package "sqlalchemy_nose" which installs along with "sqlalchemy". This so that the "nosetests" script works as always but also allows the --with-coverage option to turn on coverage before SQLAlchemy modules are imported, allowing coverage to work correctly. - added some new ignores --- .hgignore | 3 +++ CHANGES | 11 ++++++++++- lib/sqlalchemy/test/__init__.py | 3 ++- lib/sqlalchemy/test/engines.py | 2 +- lib/sqlalchemy/test/profiling.py | 2 +- lib/sqlalchemy/test/testing.py | 3 ++- lib/sqlalchemy_nose/__init__.py | 0 lib/{sqlalchemy/test => sqlalchemy_nose}/config.py | 0 .../test => sqlalchemy_nose}/noseplugin.py | 10 +++++++--- setup.py | 12 ++++++------ test/__init__.py | 1 - 11 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 lib/sqlalchemy_nose/__init__.py rename lib/{sqlalchemy/test => sqlalchemy_nose}/config.py (100%) rename lib/{sqlalchemy/test => sqlalchemy_nose}/noseplugin.py (96%) diff --git a/.hgignore b/.hgignore index ef7855faec..a4a0ce2bc8 100755 --- a/.hgignore +++ b/.hgignore @@ -4,4 +4,7 @@ syntax:regexp .pyc$ .orig$ .egg-info +.*,cover +\.coverage +\.DS_Store test.cfg diff --git a/CHANGES b/CHANGES index a2e864bdac..7f055ea7af 100644 --- a/CHANGES +++ b/CHANGES @@ -202,7 +202,16 @@ CHANGES - *Major* cleanup / modernization of the Informix dialect for 0.6, courtesy Florian Apolloner. [ticket:1906] - + +- tests + - the NoseSQLAlchemyPlugin has been moved to a + new package "sqlalchemy_nose" which installs + along with "sqlalchemy". This so that the "nosetests" + script works as always but also allows the + --with-coverage option to turn on coverage before + SQLAlchemy modules are imported, allowing coverage + to work correctly. + - misc - CircularDependencyError now has .cycles and .edges members, which are the set of elements involved in diff --git a/lib/sqlalchemy/test/__init__.py b/lib/sqlalchemy/test/__init__.py index d69cedefdd..7356945d20 100644 --- a/lib/sqlalchemy/test/__init__.py +++ b/lib/sqlalchemy/test/__init__.py @@ -6,7 +6,8 @@ by noseplugin.NoseSQLAlchemy. """ -from sqlalchemy.test import testing, engines, requires, profiling, pickleable, config +from sqlalchemy_nose import config +from sqlalchemy.test import testing, engines, requires, profiling, pickleable from sqlalchemy.test.schema import Column, Table from sqlalchemy.test.testing import \ AssertsCompiledSQL, \ diff --git a/lib/sqlalchemy/test/engines.py b/lib/sqlalchemy/test/engines.py index 9e77f38d71..870f984ecf 100644 --- a/lib/sqlalchemy/test/engines.py +++ b/lib/sqlalchemy/test/engines.py @@ -1,6 +1,6 @@ import sys, types, weakref from collections import deque -import config +from sqlalchemy_nose import config from sqlalchemy.util import function_named, callable import re import warnings diff --git a/lib/sqlalchemy/test/profiling.py b/lib/sqlalchemy/test/profiling.py index c5256affa4..835253a3a9 100644 --- a/lib/sqlalchemy/test/profiling.py +++ b/lib/sqlalchemy/test/profiling.py @@ -6,7 +6,7 @@ in a more fine-grained way than nose's profiling plugin. """ import os, sys -from sqlalchemy.test import config +from sqlalchemy_nose import config from sqlalchemy.test.util import function_named, gc_collect from nose import SkipTest diff --git a/lib/sqlalchemy/test/testing.py b/lib/sqlalchemy/test/testing.py index 41ba3038f2..471044742f 100644 --- a/lib/sqlalchemy/test/testing.py +++ b/lib/sqlalchemy/test/testing.py @@ -8,7 +8,8 @@ import types import warnings from cStringIO import StringIO -from sqlalchemy.test import config, assertsql, util as testutil +from sqlalchemy_nose import config +from sqlalchemy.test import assertsql, util as testutil from sqlalchemy.util import function_named, py3k from engines import drop_all_tables diff --git a/lib/sqlalchemy_nose/__init__.py b/lib/sqlalchemy_nose/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/sqlalchemy/test/config.py b/lib/sqlalchemy_nose/config.py similarity index 100% rename from lib/sqlalchemy/test/config.py rename to lib/sqlalchemy_nose/config.py diff --git a/lib/sqlalchemy/test/noseplugin.py b/lib/sqlalchemy_nose/noseplugin.py similarity index 96% rename from lib/sqlalchemy/test/noseplugin.py rename to lib/sqlalchemy_nose/noseplugin.py index 6a3106e69d..8732142f7d 100644 --- a/lib/sqlalchemy/test/noseplugin.py +++ b/lib/sqlalchemy_nose/noseplugin.py @@ -10,9 +10,9 @@ import StringIO import nose.case from nose.plugins import Plugin -from sqlalchemy import util, log as sqla_log -from sqlalchemy.test import testing, config, requires -from sqlalchemy.test.config import ( +from sqlalchemy_nose import config + +from sqlalchemy_nose.config import ( _create_testing_engine, _engine_pool, _engine_strategy, _engine_uri, _list_dbs, _log, _prep_testing_database, _require, _reverse_topological, _server_side_cursors, _set_table_options, base_config, db, db_label, db_url, file_config, post_configure) @@ -78,6 +78,10 @@ class NoseSQLAlchemy(Plugin): self.options = options def begin(self): + global testing, requires, util + from sqlalchemy.test import testing, requires + from sqlalchemy import util + testing.db = db testing.requires = requires diff --git a/setup.py b/setup.py index 76cba05845..7a8a0f3f26 100644 --- a/setup.py +++ b/setup.py @@ -56,11 +56,11 @@ elif BUILD_CEXTENSIONS: def find_packages(dir_): packages = [] - for _dir, subdirectories, files in os.walk(os.path.join(dir_, - 'sqlalchemy')): - if '__init__.py' in files: - lib, fragment = _dir.split(os.sep, 1) - packages.append(fragment.replace(os.sep, '.')) + for pkg in ['sqlalchemy', 'sqlalchemy_nose']: + for _dir, subdirectories, files in os.walk(os.path.join(dir_, pkg)): + if '__init__.py' in files: + lib, fragment = _dir.split(os.sep, 1) + packages.append(fragment.replace(os.sep, '.')) return packages if sys.version_info < (2, 4): @@ -90,7 +90,7 @@ setup(name = "SQLAlchemy", test_suite = "nose.collector", entry_points = { 'nose.plugins.0.10': [ - 'sqlalchemy = sqlalchemy.test.noseplugin:NoseSQLAlchemy', + 'sqlalchemy = sqlalchemy_nose.noseplugin:NoseSQLAlchemy', ] }, diff --git a/test/__init__.py b/test/__init__.py index 8b13789179..e69de29bb2 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1 +0,0 @@ - -- 2.47.2