-
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.
Merge pull request #11 from cnerg/3-add-pyprojecttoml-and-arrange-fil…
…es-per-standards
- Loading branch information
Showing
9 changed files
with
154 additions
and
30 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
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,2 @@ | ||
# make piano a top-level class | ||
from .piano import Piano |
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,19 @@ | ||
from . import Piano | ||
|
||
""" | ||
This is a special file that makes this package executable. | ||
It will only be run when this package is run from the command line, i.e., | ||
``python -m acme_corp`` | ||
""" | ||
|
||
|
||
def set_trap(): | ||
piano = Piano() | ||
piano.lift() | ||
return piano | ||
|
||
|
||
if __name__ == "__main__": | ||
trap = set_trap() |
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,42 @@ | ||
class Piano: | ||
""" | ||
A grand piano proudly built by ACME corporation. | ||
Weighing half a ton be careful when hoisting this precariously over | ||
sidewalks. | ||
.. warning:: | ||
Always use proper rigging techniques when hoisting this above | ||
above any paths that may be occupied by any Road Runners. | ||
""" | ||
|
||
def __init__(self): | ||
self._weight = 1_000 | ||
# start on ground level | ||
self._height = 0 | ||
|
||
def lift(self): | ||
self._height = 3 # [m] | ||
|
||
def drop(self): | ||
pass | ||
|
||
@property | ||
def weight(self): | ||
""" | ||
The current weight of the piano. | ||
:returns: the current weight. | ||
:rtype: float | ||
""" | ||
return self._weight | ||
|
||
@property | ||
def height(self): | ||
""" | ||
The current height of the piano. | ||
:returns: the current height. | ||
:rtype: float | ||
""" | ||
return self._height |
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,35 @@ | ||
# reference: <https://packaging.python.org/en/latest/guides/writing-pyproject-toml/> | ||
[project] | ||
name = "acme_corp" | ||
description = "A package, or box, created by the Acme Corporation for all of your Road Runner hunting needs." | ||
# use semantic versioning: <https://semver.org/> | ||
version = "0.0.1" | ||
|
||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
maintainers = [{name = "G. C. Runner", email = "[email protected]"}] | ||
authors = [{name = "G. C. Runner", email = "[email protected]"}] | ||
|
||
keywords = ["Piano", "Anvil", "Instant Tunnel"] | ||
|
||
# these will be install with `pip install .` | ||
dependencies = ["pyyaml"] | ||
|
||
# these will only be installed with `pip install .[test]` | ||
[project.optional-dependencies] | ||
test =["pytest"] | ||
|
||
[project.scripts] | ||
do_thing = "acme_corp:do_task.do_task" | ||
|
||
# these show up on the left bar on pypi.org | ||
[project.urls] | ||
Homepage = "https://github.com/cnerg/py-template" | ||
|
||
[build-system] | ||
requires = ["setuptools>=64.0.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tools.pytest.ini_options] | ||
minversion = "6.0" | ||
junit_logging = "all" |
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
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,22 @@ | ||
import acme_corp | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def blank_piano(): | ||
return acme_corp.Piano() | ||
|
||
|
||
def test_piano_init(blank_piano): | ||
assert blank_piano.weight == pytest.approx(1_000.0) | ||
assert blank_piano.height == pytest.approx(0.0) | ||
|
||
|
||
def test_lifting_piano(blank_piano): | ||
blank_piano.lift() | ||
assert blank_piano.height == pytest.approx(3) | ||
|
||
|
||
def test_dropping_piano(blank_piano): | ||
pass |