Skip to content

Commit

Permalink
Removed Python 2 & PyYAML<5.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mzulqarnain1 committed Feb 25, 2022
1 parent b34597d commit de7028a
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 58 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish package to PyPI

on:
release:
types: [published]

jobs:

push:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install pip
run: pip install setuptools wheel

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python CI

on:
push:
branches: [master]
pull_request:
branches:
- '**'

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8', '3.9']
toxenv: ['py']

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install setuptools wheel tox
pip install .
- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox -- --hypothesis-profile=ci
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ build
dist

.vscode
venv
venv

.idea/
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Flask-Fixtures
Flask-YAML-Fixtures
==============
A fork of (Flask-Fixtures by Christopher Roach)[https://github.com/croach/FLask-Fixtures] that works with latest version of PyYAML.

A simple library that allows you to add database fixtures for your unit
tests using nothing but JSON or YAML.

Installation
------------

Installing Flask-Fixtures is simple, just do a typical pip install like
Installing FLask-YAML-Fixtures is simple, just do a typical pip install like
so:

::

pip install flask-fixtures
pip install flask-yaml-fixtures

If you are going to use JSON as your data serialization format, you
should also consider installing the dateutil package since it will
Expand All @@ -24,16 +25,16 @@ install command.

::

git clone https://github.com/croach/Flask-Fixtures.git
git clone https://github.com/mzulqarnain1/Flask-YAML-Fixtures.git
cd /path/to/flask-fixtures
python setup.py install

Setup
-----

To setup the library, you simply need to tell Flask-Fixtures where it
To setup the library, you simply need to tell FLask-YAML-Fixtures where it
can find the fixtures files for your tests. Fixtures can reside anywhere
on the file system, but by default, Flask-Fixtures looks for these files
on the file system, but by default, FLask-YAML-Fixtures looks for these files
in a directory called ``fixtures`` in your app's root directory. To add
more directories to the list to be searched, just add an attribute
called ``FIXTURES_DIRS`` to your app's config object. This attribute
Expand Down Expand Up @@ -208,21 +209,21 @@ fixtures.
Usage
-----

To use Flask-Fixtures in your unit tests, you'll need to make sure your
To use FLask-YAML-Fixtures in your unit tests, you'll need to make sure your
test class inherits from ``FixturesMixin`` and that you've specified a
list of fixtures files to load. The sample code below shows how to do
each these steps.

First, make sure the app that you're testing is initialized with the proper
configuration. Then import and initialize the ``FixturesMixin`` class, create
a new test class, and inherit from ``FixturesMixin``. Now you just need to
tell Flask-Fixtures which fixtures files to use for your tests. You can do so
tell FLask-YAML-Fixtures which fixtures files to use for your tests. You can do so
by setting the ``fixtures`` class variable. Doing so will setup and tear down
fixtures between each test. To persist fixtures across tests, i.e., to setup
fixtures only when the class is first created and tear them down after all
tests have finished executing, you'll need to set the ``persist_fixtures``
variable to True. The ``fixtures`` variable should be set to a list of
strings, each of which is the name of a fixtures file to load. Flask-Fixtures
strings, each of which is the name of a fixtures file to load. FLask-YAML-Fixtures
will then search the default fixtures directory followed by each directory in
the ``FIXTURES_DIRS`` config variable, in order, for a file matching each name
in the list and load each into the test database.
Expand Down Expand Up @@ -274,14 +275,14 @@ Examples
To see the library in action, you can find a simple Flask application
and set of unit tests matching the ones in the example above in the
``tests/myapp`` directory. To run these examples yourself, just follow
the directions below for "Contributing to Flask-Fixtures".
the directions below for "Contributing to FLask-YAML-Fixtures".

Contributing to Flask-Fixtures
Contributing to FLask-YAML-Fixtures
------------------------------

Currently, Flask-Fixtures supports python versions 2.6 and 2.7 and the
Currently, FLask-YAML-Fixtures supports python versions 3.8+ and the
py.test, nose, and unittest (included in the python standard library)
libraries. To contribute bug fixes and features to Flask-Fixtures,
libraries. To contribute bug fixes and features to FLask-YAML-Fixtures,
you'll need to make sure that any code you contribute does not break any
of the existing unit tests in any of these environments.

Expand Down
3 changes: 1 addition & 2 deletions flask_fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from . import loaders
from .utils import can_persist_fixtures
import six
import importlib

from flask import current_app
Expand Down Expand Up @@ -252,7 +251,7 @@ def child_fn(obj):
return default_fn


class FixturesMixin(six.with_metaclass(MetaFixturesMixin, object)):
class FixturesMixin(metaclass=MetaFixturesMixin):

fixtures = None
app = None
Expand Down
5 changes: 2 additions & 3 deletions flask_fixtures/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import logging

from .utils import print_info
import six

try:
from dateutil.parser import parse as dtparse
Expand Down Expand Up @@ -45,7 +44,7 @@ def load(self, filename):
log = logging.getLogger(__name__)


class FixtureLoader(six.with_metaclass(abc.ABCMeta, object)):
class FixtureLoader(metaclass=abc.ABCMeta):
@abc.abstractmethod
def load(self):
pass
Expand Down Expand Up @@ -74,7 +73,7 @@ class YAMLLoader(FixtureLoader):

def load(self, filename):
with open(filename) as fin:
return yaml.load(fin)
return yaml.safe_load(fin)


def load(filename):
Expand Down
63 changes: 29 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Flask-Fixtures
Flask-YAML-Fixtures
--------------
A fixtures library for testing Flask apps.
Expand All @@ -12,55 +12,50 @@


root_dir = os.path.abspath(os.path.dirname(__file__))
package_dir = os.path.join(root_dir, 'flask_fixtures')
package_dir = os.path.join(root_dir, "flask_fixtures")


# Try to get the long description from the README file or the module's
# docstring if the README isn't available.
try:
README = open(os.path.join(root_dir, 'README.rst')).read()
README = open(os.path.join(root_dir, "README.rst")).read()
except:
README = __doc__

install_requires = [
'Flask',
'Flask-SQLAlchemy',
'six'
]
install_requires = ["Flask", "Flask-SQLAlchemy", "PyYAML>5.1"]
try:
import importlib
except ImportError:
install_requires.append('importlib')
install_requires.append("importlib")

setup(
name='Flask-Fixtures',
version='0.3.8',
url='https://github.com/croach/Flask-Fixtures',
license='MIT License',
author='Christopher Roach',
author_email='vthakr@gmail.com',
maintainer='Christopher Roach',
maintainer_email='vthakr@gmail.com',
description='A simple library for adding database fixtures for unit tests using nothing but JSON or YAML.',
name="Flask-YAML-Fixtures",
version="0.4.0",
url="https://github.com/mzulqarnain1/Flask-Fixtures",
license="MIT License",
author="Muhammad Zulqarnain",
author_email="zulqarnain.mailbox@gmail.com",
maintainer="Muhammad Zulqarnain",
maintainer_email="zulqarnain.mailbox@gmail.com",
description="A simple library for adding database fixtures for unit tests using nothing but JSON or YAML.",
long_description=README,
# py_modules=['flask_fixtures'],
# if you would be using a package instead use packages instead
# of py_modules:
install_requires=install_requires,
packages=['flask_fixtures'],
packages=["flask_fixtures"],
zip_safe=False,
include_package_data=True,
platforms='any',

platforms="any",
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Testing'
]
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Framework :: Flask",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
],
)
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {py26,py27}-flask-{pre-app-ctx,post-app-ctx},py36-post-app-ctx
envlist = py{38,39}

[testenv]
changedir = tests
Expand All @@ -8,10 +8,8 @@ commands =
py.test -s
nosetests --nologcapture -s
deps =
flask-pre-app-ctx: Flask < 0.9
flask-pre-app-ctx: Flask-SQLAlchemy < 2.2
flask-post-app-ctx: Flask >= 0.9
flask-post-app-ctx: Flask-SQLAlchemy >= 2.2
Flask >= 0.9
Flask-SQLAlchemy >= 2.2
discover
nose
pytest
Expand Down

0 comments on commit de7028a

Please sign in to comment.