diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29a7e881..2b381638 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ concurrency: jobs: tests: - name: Python ${{ matrix.python-version }}, Database ${{ matrix.database-type }} + name: Python ${{ matrix.python-version }} runs-on: ubuntu-latest strategy: @@ -26,17 +26,6 @@ jobs: - "3.12" - "pypy-3.9" - "pypy-3.10" - database-type: - - "sqlite" - - "postgres" - - services: - postgresdb: - image: postgres:alpine - ports: - - 5432:5432 - env: - POSTGRES_PASSWORD: password steps: - uses: actions/checkout@v4 diff --git a/README.rst b/README.rst index 3d3677bf..cd926690 100644 --- a/README.rst +++ b/README.rst @@ -405,11 +405,9 @@ To test with a specific framework version, you may use a ``tox`` target: # run tests inside a specific environment (django) $ tox -e py310-djangomain - $ tox -e py310-djangomain-postgres # run tests inside a specific environment (alchemy) $ tox -e py310-alchemy - $ tox -e py310-alchemy-postgres # run tests inside a specific environment (mongoengine) $ tox -e py310-mongo diff --git a/setup.cfg b/setup.cfg index 1882a205..d22ae33e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,7 +49,6 @@ dev = mypy Pillow SQLAlchemy - sqlalchemy_utils mongoengine mongomock wheel>=0.32.0 diff --git a/tests/alchemyapp/models.py b/tests/alchemyapp/models.py index 20e60aab..42e05176 100644 --- a/tests/alchemyapp/models.py +++ b/tests/alchemyapp/models.py @@ -2,34 +2,11 @@ """Helpers for testing SQLAlchemy apps.""" -import os from sqlalchemy import Column, Integer, Unicode, create_engine from sqlalchemy.orm import declarative_base, scoped_session, sessionmaker -try: - import psycopg2 # noqa: F401 - USING_POSTGRES = True -except ImportError: - try: - # pypy does not support `psycopg2` or `psycopg2-binary` - # This is a package that only gets installed with pypy, and it needs to be - # initialized for it to work properly. It mimic `psycopg2` 1-to-1 - from psycopg2cffi import compat - compat.register() - USING_POSTGRES = True - except ImportError: - USING_POSTGRES = False - -if USING_POSTGRES: - pg_database = 'alch_' + os.environ.get('POSTGRES_DATABASE', 'factory_boy_test') - pg_user = os.environ.get('POSTGRES_USER', 'postgres') - pg_password = os.environ.get('POSTGRES_PASSWORD', 'password') - pg_host = os.environ.get('POSTGRES_HOST', 'localhost') - pg_port = os.environ.get('POSTGRES_PORT', '5432') - engine_name = f'postgresql+psycopg2://{pg_user}:{pg_password}@{pg_host}:{pg_port}/{pg_database}' -else: - engine_name = 'sqlite://' +engine_name = 'sqlite://' session = scoped_session(sessionmaker()) engine = create_engine(engine_name) diff --git a/tests/djapp/settings_pg.py b/tests/djapp/settings_pg.py deleted file mode 100644 index de54922c..00000000 --- a/tests/djapp/settings_pg.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright: See the LICENSE file. - -"""Settings for factory_boy/Django tests.""" - -import os - -from .settings import * # noqa: F401, F403 - -try: - # pypy does not support `psycopg2` or `psycopg2-binary` - # This is a package that only gets installed with pypy, and it needs to be - # initialized for it to work properly. It mimic `psycopg2` 1-to-1 - from psycopg2cffi import compat - compat.register() -except ImportError: - pass - -postgres_user = os.environ.get('POSTGRES_USER', 'postgres') -postgres_name = os.environ.get('POSTGRES_DATABASE', 'factory_boy_test') -postgres_password = os.environ.get('POSTGRES_PASSWORD', 'password') -postgres_host = os.environ.get('POSTGRES_HOST', 'localhost') -postgres_port = os.environ.get('POSTGRES_PORT', '5432') - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': postgres_name, - 'USER': postgres_user, - 'PASSWORD': postgres_password, - 'HOST': postgres_host, - 'PORT': postgres_port, - }, - 'replica': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': postgres_name + '_rp', - 'USER': postgres_user, - 'PASSWORD': postgres_password, - 'HOST': postgres_host, - 'PORT': postgres_port, - } -} diff --git a/tests/test_alchemy.py b/tests/test_alchemy.py index 19e4f5ee..6b568ce4 100644 --- a/tests/test_alchemy.py +++ b/tests/test_alchemy.py @@ -10,8 +10,6 @@ except ImportError: raise unittest.SkipTest("sqlalchemy tests disabled.") -from sqlalchemy_utils import create_database, database_exists, drop_database - import factory from factory.alchemy import SQLAlchemyModelFactory @@ -77,17 +75,6 @@ class Meta: text = factory.Sequence(lambda n: "text%s" % n) -if models.USING_POSTGRES: - # sqlite test database gets created/destroyed automatically, postgres does not. - - def setUpModule(): - if not database_exists(models.engine.url): - create_database(models.engine.url) - - def tearDownModule(): - drop_database(models.engine.url) - - class TransactionTestCase(unittest.TestCase): def setUp(self): models.Base.metadata.create_all(models.engine) diff --git a/tox.ini b/tox.ini index ca21be5c..4d5438e1 100644 --- a/tox.ini +++ b/tox.ini @@ -5,13 +5,12 @@ envlist = docs examples linkcheck - py{38,39,310,311,312,py39,py310}-sqlite - py{38,39,310,311,py39,py310}-django32-mongo-alchemy-{sqlite,postgres} - py{38,39,310,311,312}-django42-mongo-alchemy-{sqlite,postgres} - py{py39,py310}-django42-mongo-alchemy-sqlite, - # py{py39,py310}-django42-mongo-alchemy-postgres # TODO: Fix me! - py{310,311,312}-django50-mongo-alchemy-{sqlite,postgres} - py310-djangomain-mongo-alchemy-{sqlite,postgres} + py{38,39,310,311,312,py39,py310} + py{38,39,310,311,py39,py310}-django32-mongo-alchemy + py{38,39,310,311,312}-django42-mongo-alchemy + py{py39,py310}-django42-mongo-alchemy + py{310,311,312}-django50-mongo-alchemy + py310-djangomain-mongo-alchemy [gh-actions] python = @@ -23,19 +22,10 @@ python = pypy-3.9: pypy39 pypy-3.10: pypy310 -[gh-actions:env] -DATABASE_TYPE = - sqlite: sqlite - postgres: postgres - [testenv] -passenv = - POSTGRES_HOST - POSTGRES_DATABASE deps = mypy alchemy: SQLAlchemy - alchemy: sqlalchemy_utils mongo: mongoengine mongo: mongomock # mongomock imports pkg_resources, provided by setuptools. @@ -45,12 +35,9 @@ deps = django42: Django>=4.2,<5.0 django50: Django>=5.0,<5.1 djangomain: https://github.com/django/django/archive/main.tar.gz - py{38,39,310,311,312}-postgres: psycopg2-binary - pypy{39,310}-postgres: psycopg2cffi setenv = py: DJANGO_SETTINGS_MODULE=tests.djapp.settings - postgres: DJANGO_SETTINGS_MODULE=tests.djapp.settings_pg allowlist_externals = make commands = make test