Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
svenhofstede committed Feb 24, 2024
0 parents commit 8ff3e4e
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: main

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8']
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install tox
run: pip install tox

- name: Test
run: tox -e py
77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
.pytest_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask instance folder
instance/

# Sphinx documentation
docs/_build/

# MkDocs documentation
/site/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version


# Pycharm
.idea
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2024 Sven Hofstede

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
76 changes: 76 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
=============
pytest-kuunda
=============

.. image:: https://img.shields.io/pypi/v/pytest-kuunda.svg
:target: https://pypi.org/project/pytest-kuunda
:alt: PyPI version

.. image:: https://img.shields.io/pypi/pyversions/pytest-kuunda.svg
:target: https://pypi.org/project/pytest-kuunda
:alt: Python versions

.. image:: https://github.com/svenhofstede/pytest-kuunda/actions/workflows/main.yml/badge.svg
:target: https://github.com/svenhofstede/pytest-kuunda/actions/workflows/main.yml
:alt: See Build Status on GitHub Actions

pytest plugin to help with test data setup for PySpark tests

----

This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.


Features
--------

* TODO


Requirements
------------

* TODO


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

You can install "pytest-kuunda" via `pip`_ from `PyPI`_::

$ pip install pytest-kuunda


Usage
-----

* TODO

Contributing
------------
Contributions are very welcome. Tests can be run with `tox`_, please ensure
the coverage at least stays the same before you submit a pull request.

License
-------

Distributed under the terms of the `MIT`_ license, "pytest-kuunda" is free and open source software


Issues
------

If you encounter any problems, please `file an issue`_ along with a detailed description.

.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
.. _`@hackebrot`: https://github.com/hackebrot
.. _`MIT`: https://opensource.org/licenses/MIT
.. _`BSD-3`: https://opensource.org/licenses/BSD-3-Clause
.. _`GNU GPL v3.0`: https://www.gnu.org/licenses/gpl-3.0.txt
.. _`Apache Software License 2.0`: https://www.apache.org/licenses/LICENSE-2.0
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _`file an issue`: https://github.com/svenhofstede/pytest-kuunda/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Welcome to pytest-kuunda

pytest plugin to help with test data setup for PySpark tests
10 changes: 10 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
site_name: pytest-kuunda
site_description: pytest plugin to help with test data setup for PySpark tests
site_author: Sven Hofstede

theme: readthedocs

repo_url: https://github.com/svenhofstede/pytest-kuunda

pages:
- Home: index.md
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = [
"setuptools>=61.0.0",
]
build-backend = "setuptools.build_meta"

[project]
name = "pytest-kuunda"
description = "pytest plugin to help with test data setup for PySpark tests"
version = "0.1.0"
readme = "README.rst"
requires-python = ">=3.8"
authors = [
{ name = "Sven Hofstede", email = "info@svenhofstede.com" },
]
maintainers = [
{ name = "Sven Hofstede", email = "info@svenhofstede.com" },
]
license = {file = "LICENSE"}
classifiers = [
"Framework :: Pytest",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"pytest>=6.2.0",
]
[project.urls]
Repository = "https://github.com/svenhofstede/pytest-kuunda"
[project.entry-points.pytest11]
django = "pytest_kuunda.plugin"
Empty file added src/pytest_kuunda/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions src/pytest_kuunda/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest


def pytest_addoption(parser):
group = parser.getgroup('kuunda')
group.addoption(
'--foo',
action='store',
dest='dest_foo',
default='2024',
help='Set the value for the fixture "bar".'
)

parser.addini('HELLO', 'Dummy pytest.ini setting')


@pytest.fixture
def bar(request):
return request.config.option.dest_foo
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest_plugins = 'pytester'
61 changes: 61 additions & 0 deletions tests/test_kuunda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
def test_bar_fixture(pytester):
"""Make sure that pytest accepts our fixture."""

# create a temporary pytest test module
pytester.makepyfile("""
def test_sth(bar):
assert bar == "europython2015"
""")

# run pytest with the following cmd args
result = pytester.runpytest(
'--foo=europython2015',
'-v'
)

# fnmatch_lines does an assertion internally
result.stdout.fnmatch_lines([
'*::test_sth PASSED*',
])

# make sure that we get a '0' exit code for the testsuite
assert result.ret == 0


def test_help_message(pytester):
result = pytester.runpytest(
'--help',
)
# fnmatch_lines does an assertion internally
result.stdout.fnmatch_lines([
'kuunda:',
'*--foo=DEST_FOO*Set the value for the fixture "bar".',
])


def test_hello_ini_setting(pytester):
pytester.makeini("""
[pytest]
HELLO = world
""")

pytester.makepyfile("""
import pytest
@pytest.fixture
def hello(request):
return request.config.getini('HELLO')
def test_hello_world(hello):
assert hello == 'world'
""")

result = pytester.runpytest('-v')

# fnmatch_lines does an assertion internally
result.stdout.fnmatch_lines([
'*::test_hello_world PASSED*',
])

# make sure that we get a '0' exit code for the testsuite
assert result.ret == 0
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py38,py39,py310,py311,py312,pypy3,flake8

[testenv]
deps = pytest>=6.2.0
commands = pytest {posargs:tests}

[testenv:flake8]
skip_install = true
deps = flake8
commands = flake8 src tests

0 comments on commit 8ff3e4e

Please sign in to comment.