From 41f3f11afc24ec69aea28ece9fa2bf40a66f8292 Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Thu, 17 Oct 2024 16:36:53 +0200 Subject: [PATCH] Updated christmas tree --- .../christmas-tree-python/poetry.lock | 51 +------------------ .../christmas-tree-python/pyproject.toml | 3 +- .../christmas-tree-python/run_tests.sh | 2 +- .../christmas-tree-python/run_watch.sh | 2 +- .../christmas-tree-python/test/tree_spec.py | 24 --------- .../christmas-tree-python/test/tree_test.py | 42 +++++++++++++++ 6 files changed, 47 insertions(+), 77 deletions(-) delete mode 100644 kata-solutions/christmas-tree/christmas-tree-python/test/tree_spec.py create mode 100644 kata-solutions/christmas-tree/christmas-tree-python/test/tree_test.py diff --git a/kata-solutions/christmas-tree/christmas-tree-python/poetry.lock b/kata-solutions/christmas-tree/christmas-tree-python/poetry.lock index 36b6e097..7217423b 100644 --- a/kata-solutions/christmas-tree/christmas-tree-python/poetry.lock +++ b/kata-solutions/christmas-tree/christmas-tree-python/poetry.lock @@ -1,27 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. - -[[package]] -name = "args" -version = "0.1.0" -description = "Command Arguments for Humans." -optional = false -python-versions = "*" -files = [ - {file = "args-0.1.0.tar.gz", hash = "sha256:a785b8d837625e9b61c39108532d95b85274acd679693b71ebb5156848fcf814"}, -] - -[[package]] -name = "clint" -version = "0.5.1" -description = "Python Command Line Interface Tools" -optional = false -python-versions = "*" -files = [ - {file = "clint-0.5.1.tar.gz", hash = "sha256:05224c32b1075563d0b16d0015faaf9da43aa214e4a2140e51f08789e7a4c5aa"}, -] - -[package.dependencies] -args = "*" +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "colorama" @@ -132,16 +109,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "expects" -version = "0.9.0" -description = "Expressive and extensible TDD/BDD assertion library for Python" -optional = false -python-versions = "*" -files = [ - {file = "expects-0.9.0.tar.gz", hash = "sha256:419902ccafe81b7e9559eeb6b7a07ef9d5c5604eddb93000f0642b3b2d594f4c"}, -] - [[package]] name = "iniconfig" version = "2.0.0" @@ -153,20 +120,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "mamba" -version = "0.11.3" -description = "The definitive testing tool for Python. Born under the banner of Behavior Driven Development." -optional = false -python-versions = "*" -files = [ - {file = "mamba-0.11.3.tar.gz", hash = "sha256:4dcf69e9a53e78d4aa5ec3dee0bb2c65f02ea68a6b62c4275653d7170b8f5fe2"}, -] - -[package.dependencies] -clint = "*" -coverage = "*" - [[package]] name = "packaging" version = "24.1" @@ -304,4 +257,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.10.0,<=3.13" -content-hash = "653687f3288782c56f0596609a30d6d51f4d851b2744ffb178eaae6cec5340a6" +content-hash = "a98c7882db635a70cff291e35fdc9503d221a76928d6adb1e7e4c831761b149f" diff --git a/kata-solutions/christmas-tree/christmas-tree-python/pyproject.toml b/kata-solutions/christmas-tree/christmas-tree-python/pyproject.toml index bfa803a7..1b136435 100644 --- a/kata-solutions/christmas-tree/christmas-tree-python/pyproject.toml +++ b/kata-solutions/christmas-tree/christmas-tree-python/pyproject.toml @@ -6,11 +6,10 @@ authors = ["Zeger Hendrikse "] [tool.poetry.dependencies] python = ">=3.10.0,<=3.13" -mamba = "^0.11.2" -expects = "^0.9.0" pytest-watch = "^4.2.0" coverage = "^7.6.3" pyhamcrest = "^2.1.0" +pytest = "^8.3.3" [tool.poetry.dev-dependencies] diff --git a/kata-solutions/christmas-tree/christmas-tree-python/run_tests.sh b/kata-solutions/christmas-tree/christmas-tree-python/run_tests.sh index 0828f618..c7c20e0a 100755 --- a/kata-solutions/christmas-tree/christmas-tree-python/run_tests.sh +++ b/kata-solutions/christmas-tree/christmas-tree-python/run_tests.sh @@ -1 +1 @@ -PYTHONPATH=src poetry run mamba --format=documentation test/tree_spec.py --enable-coverage && poetry run coverage html +poetry run pytest diff --git a/kata-solutions/christmas-tree/christmas-tree-python/run_watch.sh b/kata-solutions/christmas-tree/christmas-tree-python/run_watch.sh index f13aefc4..0d5303c1 100755 --- a/kata-solutions/christmas-tree/christmas-tree-python/run_watch.sh +++ b/kata-solutions/christmas-tree/christmas-tree-python/run_watch.sh @@ -1 +1 @@ -PYTHONPATH=src poetry run ptw --runner="poetry run mamba --format=documentation --enable-coverage test/tree_spec.py" +poetry run ptw diff --git a/kata-solutions/christmas-tree/christmas-tree-python/test/tree_spec.py b/kata-solutions/christmas-tree/christmas-tree-python/test/tree_spec.py deleted file mode 100644 index 1ee6d12b..00000000 --- a/kata-solutions/christmas-tree/christmas-tree-python/test/tree_spec.py +++ /dev/null @@ -1,24 +0,0 @@ -from mamba import description, it, context, before -from expects import expect, equal, raise_error, be_false, be_true - -from tree import * - -with description("Christmas tree") as self: - with it("returns trunk when height is zero or less"): - expect(christmas_tree(0)).to(equal(["|"])) - - with it("returns a tree when height is 1"): - expect(christmas_tree(1)).to(equal(["*", - "|"])) - - with it("returns a tree when height is 2"): - expect(christmas_tree(2)).to(equal([" * ", - "***", - " | "])) - - with it("returns a tree when height is 3"): - expect(christmas_tree(3)).to(equal([" * ", - " *** ", - "*****", - " | "])) - diff --git a/kata-solutions/christmas-tree/christmas-tree-python/test/tree_test.py b/kata-solutions/christmas-tree/christmas-tree-python/test/tree_test.py new file mode 100644 index 00000000..2820182f --- /dev/null +++ b/kata-solutions/christmas-tree/christmas-tree-python/test/tree_test.py @@ -0,0 +1,42 @@ +import pytest +from hamcrest import * + +def christmas_tree(height): + if height == 1: + return ["*", + "|"] + elif height == 2: + return [" *", + "***", + " |"] + elif height ==3: + return [" *", + " ***", + "*****", + " |"] + return ["|"] + +class TestChristmasTree: + + def test_a_new_ChristmasTree_0(self): + assert_that(christmas_tree(0), + equal_to(["|"])) + + def test_a_new_ChristmasTree_1(self): + assert_that(christmas_tree(1), + equal_to(["*", + "|"])) + + def test_a_new_ChristmasTree_2(self): + assert_that(christmas_tree(2), + equal_to([" *", + "***", + " |"])) + + def test_a_new_ChristmasTree_3(self): + assert_that(christmas_tree(3), + equal_to([" *", + " ***", + "*****", + " |"])) +