Skip to content

Commit

Permalink
Merge pull request #119 from nschloe/tmp_path
Browse files Browse the repository at this point in the history
pytest: tmp_path
  • Loading branch information
nschloe authored Oct 9, 2021
2 parents bf60105 + d254d17 commit b6c6aa6
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/setup-python@v2
with:
Expand Down
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.9.1
rev: 5.9.3
hooks:
- id: isort

- repo: https://github.com/python/black
rev: 21.6b0
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.2
hooks:
- id: prettier
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default:

tag:
@if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi
curl -H "Authorization: token `cat ~/.github-access-token`" -d '{"tag_name": "{{version}}"}' https://api.github.com/repos/nschloe/{{name}}/releases
curl -H "Authorization: token `cat ~/.github-access-token`" -d '{"tag_name": "v{{version}}"}' https://api.github.com/repos/nschloe/{{name}}/releases

upload: clean
@if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi
Expand All @@ -19,7 +19,7 @@ publish: tag upload

clean:
@find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
@rm -rf *.egg-info/ src/*.egg-info/ build/ dist/ .tox/
@rm -rf *.egg-info/ src/*.egg-info/ build/ dist/ .tox/ node_modules/

dep:
npm install
Expand Down
93 changes: 47 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "tuna",
"dependencies": {
"bootstrap": "5.1.0",
"d3": "7.0.1"
"bootstrap": "5.1.2",
"d3": "7.1.1"
},
"devDependencies": {
"prettier": "^2.3.2"
"prettier": "^2.4.1"
},
"scripts": {
"prettier": "prettier --check README .github tuna/web/static/icicle.js tuna/web/static/tuna.css"
"prettier": "prettier --check README.md .github tuna/web/static/icicle.js tuna/web/static/tuna.css"
}
}
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = tuna
version = 0.5.8
version = 0.5.9
author = Nico Schlömer
author_email = [email protected]
description = Visualize Python performance profiles
Expand All @@ -22,6 +22,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Software Development :: User Interfaces
Topic :: Utilities
keywords =
Expand Down
24 changes: 10 additions & 14 deletions tests/test_tuna.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import subprocess
import tempfile
import time
from pathlib import Path

Expand All @@ -15,10 +14,9 @@ def test_tuna():
# give server time to start up
time.sleep(3)
p.terminate()
return


def test_importprofile():
def test_importprofile(tmp_path):
content = """
import time: 3 | 22 | c
import time: 2 | 15 | b
Expand All @@ -45,17 +43,16 @@ def test_importprofile():
],
}

with tempfile.TemporaryDirectory() as temp_dir:
filepath = Path(temp_dir) / "test.log"
with open(filepath, "w") as f:
f.write(content)
filepath = tmp_path / "test.log"
with open(filepath, "w") as f:
f.write(content)

out = tuna.read_import_profile(filepath)
out = tuna.read_import_profile(filepath)

assert out == ref, ref


def test_importprofile_multiprocessing():
def test_importprofile_multiprocessing(tmp_path):
# when using multiprocessing, you can have seemingly excessive indentation,
# see <https://github.com/nschloe/tuna/issues/53>
content = """
Expand Down Expand Up @@ -99,12 +96,11 @@ def test_importprofile_multiprocessing():
],
}

with tempfile.TemporaryDirectory() as temp_dir:
filepath = Path(temp_dir) / "test.log"
with open(filepath, "w") as f:
f.write(content)
filepath = tmp_path / "test.log"
with open(filepath, "w") as f:
f.write(content)

out = tuna.read_import_profile(filepath)
out = tuna.read_import_profile(filepath)

assert out == ref, ref

Expand Down

0 comments on commit b6c6aa6

Please sign in to comment.