-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PabloLec/dev
Version 0.0.3
- Loading branch information
Showing
12 changed files
with
604 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Linux | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pytests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install . | ||
pip install pytest | ||
pip install -r requirements.txt | ||
- name: Run unit tests | ||
run: | | ||
pytest -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: macOS | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pytests: | ||
runs-on: macOS-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install . | ||
pip install pytest | ||
pip install -r requirements.txt | ||
- name: Run unit tests | ||
run: | | ||
mkdir ~/testfolder | ||
sudo chmod -R u-rwx ~/testfolder | ||
pytest -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Windows | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pytest: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install . | ||
pip install pytest | ||
pip install -r requirements.txt | ||
- name: Run unit tests | ||
run: | | ||
pytest -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# livelog | ||
|
||
Work in progress | ||
[![Linux](https://github.com/PabloLec/livelog/actions/workflows/linux-tests.yml/badge.svg)](https://github.com/PabloLec/livelog/actions/workflows/linux-tests.yml)[![macOS](https://github.com/PabloLec/livelog/actions/workflows/macos-tests.yml/badge.svg)](https://github.com/PabloLec/livelog/actions/workflows/macos-tests.yml)[![Windows](https://github.com/PabloLec/livelog/actions/workflows/windows-tests.yml/badge.svg)](https://github.com/PabloLec/livelog/actions/workflows/windows-tests.yml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from os import environ | ||
|
||
environ["LIVELOG_ENV"] = "TEST" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
from os import getenv | ||
from pathlib import Path | ||
from livelog import Logger | ||
from platform import system | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def restricted_dir(): | ||
if "darwin" in system().lower(): | ||
return getenv("HOME") + "/testfolder/" | ||
else: | ||
return "/root/" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def system_is_windows(): | ||
return "windows" in system().lower() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def log_file(tmpdir_factory): | ||
return tmpdir_factory.mktemp("tmp").join("test.log") | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def default_log_file(): | ||
logger = Logger() | ||
logger.debug("It works!") | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def reader_test_file(tmpdir_factory): | ||
log_file = tmpdir_factory.mktemp("tmp").join("test.log") | ||
logger = Logger(file=log_file) | ||
logger.debug("debug") | ||
logger.info("info") | ||
logger.warn("warning") | ||
logger.error("error") | ||
|
||
return Path(log_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from subprocess import Popen, PIPE | ||
|
||
|
||
def test_default(default_log_file): | ||
print("python3 -m livelog".split()) | ||
process = Popen("python3 -m livelog".split(), stdout=PIPE) | ||
out, _ = process.communicate() | ||
assert "It works" in str(out) | ||
|
||
|
||
def test_custom_file(reader_test_file): | ||
process = Popen( | ||
f"python3 -m livelog -f {reader_test_file}".split(), | ||
stdout=PIPE, | ||
) | ||
out, _ = process.communicate() | ||
assert "debug" in str(out) | ||
|
||
|
||
def test_nocolors(reader_test_file): | ||
process = Popen( | ||
f"python3 -m livelog -f {reader_test_file} --nocolors".split(), | ||
stdout=PIPE, | ||
) | ||
out, _ = process.communicate() | ||
assert "DBUG" in str(out) | ||
assert "INFO" in str(out) | ||
assert "WARN" in str(out) | ||
assert "ERR!" in str(out) | ||
|
||
|
||
def test_custom_level(reader_test_file): | ||
process = Popen( | ||
f"python3 -m livelog -f {reader_test_file} --level=INFO --nocolors".split(), | ||
stdout=PIPE, | ||
) | ||
out, _ = process.communicate() | ||
assert "INFO" in str(out) | ||
assert "DBUG" not in str(out) |
Oops, something went wrong.