-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
103 additions
and
9 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
Empty 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
Empty file.
File renamed without changes.
File renamed without changes.
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,16 @@ | ||
def add(x, y): | ||
return x + y | ||
|
||
|
||
def subtract(x, y): | ||
return x - y | ||
|
||
|
||
def multiply(x, y): | ||
return x * y | ||
|
||
|
||
def divide(x, y): | ||
if y == 0: | ||
raise ValueError("Cannot divide by zero!") | ||
return x / y |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
# setup.py | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="easypackages", | ||
version="0.1", | ||
packages=find_packages(), | ||
install_requires=[], | ||
) |
Empty 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,28 @@ | ||
# tests/test_calculator.py | ||
|
||
import pytest | ||
|
||
from easypackages.demo import add, divide, multiply, subtract | ||
|
||
|
||
def test_add(): | ||
assert add(3, 5) == 8 | ||
assert add(-1, 1) == 0 | ||
|
||
|
||
def test_subtract(): | ||
assert subtract(10, 5) == 5 | ||
assert subtract(-1, -1) == 0 | ||
|
||
|
||
def test_multiply(): | ||
assert multiply(3, 5) == 15 | ||
assert multiply(-1, 5) == -5 | ||
|
||
|
||
def test_divide(): | ||
assert divide(10, 2) == 5 | ||
assert divide(10, 5) == 2 | ||
|
||
with pytest.raises(ValueError): | ||
divide(10, 0) |
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,37 @@ | ||
[tox] | ||
envlist = py38, py39, py310, py311, lint, coverage | ||
|
||
[testenv] | ||
deps = | ||
pytest | ||
pytest-cov | ||
requests | ||
mock | ||
commands = | ||
pytest tests/ --cov=easypackages --cov-report=term-missing | ||
|
||
[testenv:lint] | ||
deps = | ||
flake8 | ||
black | ||
isort | ||
commands = | ||
flake8 easypackages/ tests/ | ||
black --check easypackages/ tests/ | ||
isort --check-only easypackages/ tests/ | ||
|
||
[testenv:coverage] | ||
deps = | ||
coverage | ||
commands = | ||
coverage report --fail-under=22 # 将阈值设置为80% | ||
coverage html | ||
|
||
[testenv:format] | ||
description = "Auto-format the code using black and isort" | ||
deps = | ||
black | ||
isort | ||
commands = | ||
black easypackages/ tests/ | ||
isort easypackages/ tests/ |