Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #349 from metachris/tests-python2
Browse files Browse the repository at this point in the history
Run CI tests also with Python2.7
  • Loading branch information
metachris committed Oct 30, 2020
2 parents da57411 + f98d41d commit a6270a6
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 222 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
# Note: to test with Python 2.7, a downgrade in pytest is necessary - last supported is 4.6 series https://docs.pytest.org/en/stable/py27-py34-deprecation.html
name: Run the tests
name: Run the tests and demo.py

on: [push]

jobs:
test:
test-pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
sed -i 's/Sphinx.*//g' requirements_dev.txt
pip install --upgrade pip
pip install -e .
pip install -r requirements_dev.txt
- name: Lint
run: make lint

# pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Generate the docs
run: make docs

- name: Run the tests
run: make test

- name: Run demo.py
run: python examples/demo.py
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ lint: ## check style with flake8

test: ## run tests quickly with the default Python
py.test


test-all: ## run tests on every Python version with tox
tox
Expand All @@ -72,7 +72,7 @@ docs: ## generate Sphinx HTML documentation, including API docs
$(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
watchmedo shell-command -p '*.rst;*.md' -c '$(MAKE) -C docs html' -R -D .

release: clean ## package and upload a release
python setup.py sdist upload
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Features
* Licensed under the MIT license.
* Heavily inspired by the [Tornado web framework](https://github.com/tornadoweb/tornado).

<!-- ![Demo output in color](https://raw.githubusercontent.com/metachris/logzero/master/docs/_static/demo_output.png) -->


Example Usage
-------------
Expand Down Expand Up @@ -186,11 +184,22 @@ $ make lint

# Generate the docs (will auto-open in Chrome)
$ make docs

# You can enable watching mode to automatically rebuild on changes:
$ make servedocs
```

To test with Python 2.7, you can use Docker:

```shell
docker run --rm -it -v /Users/chris/stream/logzero:/mnt python:2.7 /bin/bash
```

Now you have a shell with the current directory mounted into `/mnt/` inside the container.

**Notes**

* `pytest` is the test runner
* [pytest](https://docs.pytest.org/en/latest/) is the test runner
* CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows).
* Download stats: https://pepy.tech/project/logzero

Expand Down
33 changes: 11 additions & 22 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

Robust and effective logging for Python 2 and 3.

.. image:: _static/logo.png
.. image:: _static/demo-output-with-beaver.png
:alt: Logo
:width: 300px

**Features**

Expand All @@ -28,11 +27,6 @@ Robust and effective logging for Python 2 and 3.
* Hosted on GitHub: https://github.com/metachris/logzero


.. image:: _static/demo_output.png
:alt: Demo output in color
:width: 300px


Installation
============

Expand Down Expand Up @@ -74,10 +68,9 @@ You can use `logzero` like this (logs only to the console by default):
from logzero import logger
# These log messages are sent to the console
logger.debug("hello")
logger.info("info")
logger.warning("warning")
logger.warning("warn")
logger.error("error")
# This is how you'd log an exception
Expand All @@ -86,23 +79,19 @@ You can use `logzero` like this (logs only to the console by default):
except Exception as e:
logger.exception(e)
If this was a file called ``demo.py``, the output will look like this:
# JSON logging
import logzero
logzero.json()
.. image:: _static/demo_output_with_exception.png
:alt: Demo output in color
logger.info("JSON test")
.. code-block:: console
# Start writing into a logfile
logzero.logfile("/tmp/logzero-demo.log")
[D 170705 14:59:47 demo:3] hello
[I 170705 14:59:47 demo:4] info
[W 170705 14:59:47 demo:5] warn
[E 170705 14:59:47 demo:6] error
[E 170705 14:59:47 demo:12] this is a demo exception
Traceback (most recent call last):
File "demo.py", line 10, in <module>
raise Exception("this is a demo exception")
Exception: this is a demo exception
If this was a file called ``demo.py``, the output will look like this:

.. image:: _static/demo-output-json.png
:alt: Demo output in color

Logging to files
----------------
Expand Down
1 change: 0 additions & 1 deletion docs/readme.rst

This file was deleted.

6 changes: 2 additions & 4 deletions logzero/jsonlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import re
import traceback
import importlib
from inspect import istraceback
from collections import OrderedDict
from datetime import date, datetime, time

if sys.version_info >= (3, ):
Expand All @@ -19,10 +21,6 @@
tz = None


from inspect import istraceback

from collections import OrderedDict

# skip natural LogRecord attributes
# http://docs.python.org/library/logging.html#logrecord-attributes
RESERVED_ATTRS = (
Expand Down
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pytest==6.1.2
pytest==4.6
pytest-runner==5.2
bumpversion==0.6.0
watchdog==0.10.3
flake8==3.8.4
coverage==5.3
tox==3.20.1
cryptography==3.2.1
Sphinx==3.2.1
12 changes: 0 additions & 12 deletions tox.ini

This file was deleted.

127 changes: 0 additions & 127 deletions travis_pypi_setup.py

This file was deleted.

0 comments on commit a6270a6

Please sign in to comment.