Skip to content

Commit

Permalink
Merge pull request #2 from DustinMoriarty/feature/add_tests
Browse files Browse the repository at this point in the history
Added tests and gitignore.
  • Loading branch information
DustinMoriarty authored Oct 1, 2020
2 parents 0bf4509 + 13aa2e9 commit e3917a1
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.tox
__pycache__
.python-version
*.egg-info
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ RUN apt-get update && apt-get install -y \
git

# Install tox dependencies
RUN apt-get update && apt-get install -y tox
RUN apt-get update && apt-get install -y python3 python3-pip
WORKDIR /app
RUN python3 -m pip install tox

# User installation
USER ${USR}
Expand All @@ -40,5 +41,4 @@ RUN ${PYENV_ROOT}/bin/pyenv install 3.6.11
RUN ${PYENV_ROOT}/bin/pyenv install 3.7.9
RUN ${PYENV_ROOT}/bin/pyenv install 3.8.6

CMD ["tox"]

CMD ["tox"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# docker-python-tox
Test python projects in a repeatable build environment using tox. This image is to be used as part of a CICD pipeline to test python projects. This image can also be used for local testing in order to avoid the complexity of setting up the pyenv, tox stack and macking sure that tox is being called by the correct python executable.

The application, along with the tox.ini should be placed in the /app directory at runtime.

## Installation
```bash
docker pull buildright/tox
```

## Usage
The application, along with the tox.ini should be placed in the /app directory at runtime.
4 changes: 4 additions & 0 deletions tests/mock-app/mock_app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import requests

def foo(a):
return a
16 changes: 16 additions & 0 deletions tests/mock-app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "mock-app"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.5"
requests = "^2.24.0"

[tool.poetry.dev-dependencies]
pytest = "^6.1.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
6 changes: 6 additions & 0 deletions tests/mock-app/tests/test_foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest
from mock_app import foo

def test_foo():
a = 1
assert foo(a)==a
7 changes: 7 additions & 0 deletions tests/mock-app/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tox]
envlist = py35,py36,py37,py38
isolated_build = true

[testenv]
deps = pytest
commands = pytest
2 changes: 2 additions & 0 deletions tests/test-image
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t buildright/tox:test ../
docker run -v "$PWD/mock-app/:/app" buildright/tox:test

0 comments on commit e3917a1

Please sign in to comment.