Skip to content

Commit

Permalink
Add support for virtualenv development
Browse files Browse the repository at this point in the history
  • Loading branch information
davidag committed Sep 26, 2019
1 parent 8d418b3 commit 4992318
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git
.venv
Makefile
README.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pytest_cache/*
.pydevproject
.settings
.settings/*
.venv
45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,15 @@ List of new features added to the original project commits

## Requirements

### Production

- Python 3.5+ (type hints are compatible with 3.5 upwards)

Other requirements are on the `requirements.txt` file. Install them with `pip` or similar.

### Development
## Docker Environment

- Docker and Docker Compose
- Requires Docker and Docker Compose

## Running
### Running

- copy `config.py.sample` to `config.py` and fill in.

Expand All @@ -99,18 +97,47 @@ sudo dpkg-reconfigure locales
```


## Testing
- Install requirements from `requirements-dev.txt` file.

### Testing
- Run tests:
```bash
make test
```

- To extract code coverage:
- Extract code coverage:
```bash
make coverage
```

## Virtualenv Environment

1. Create the virtual environment:
```bash
$ python3 -m venv .venv
```

2. Activate it:
```bash
$ source .venv/bin/activate
```

3. Install dependencies (in the virtual environment):
```bash
(.venv) $ pip install -r requirements.txt
(.venv) $ pip install -r requirements-dev.txt
```

4. You are now ready to run the test, extract coverage or run a testing server:
```bash
(.venv) $ # Run tests
(.venv) $ pytest

(.venv) $ # Extract coverage into './cov_html' folder
(.venv) $ pytest --cov-report html:cov_html --cov=. --cov-config .coveragerc

(.venv) $ # Run testing server
(.venv) $ python app.py
```

## Miscellaneous

### User creation/deletion
Expand Down
6 changes: 3 additions & 3 deletions test/test_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import sys


SOURCE_FOLDER = "."
SOURCE_PATHS = "*.py test"


def test_flake8_compliance() -> None:
flake8_binary = subprocess.check_output("which flake8",
shell=True,
stderr=sys.stderr).decode("ascii").replace("\n", "")

result = subprocess.call("{} {}".format(flake8_binary, SOURCE_FOLDER),
result = subprocess.call("{} {}".format(flake8_binary, SOURCE_PATHS),
shell=True,
stdout=sys.stdout,
stderr=sys.stderr)
Expand All @@ -24,7 +24,7 @@ def test_mypy_compliance() -> None:

result = subprocess.call("{} --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs"
" --warn-redundant-casts --warn-return-any --warn-unused-ignores --strict-optional"
" {}".format(mypy_binary, SOURCE_FOLDER),
" {}".format(mypy_binary, SOURCE_PATHS),
shell=True,
stdout=sys.stdout,
stderr=sys.stderr)
Expand Down

0 comments on commit 4992318

Please sign in to comment.