From 2b2d23f958b6ad0e0fcdc87dc583c0d1da4ae759 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 6 Dec 2018 23:41:49 +0200 Subject: [PATCH] Extract a method or a function. This is Refactoring / code cleanup. See: * https://refactoring.com/catalog/extractMethod.html * https://en.wikipedia.org/wiki/Code_refactoring * https://www.refactoring.com/ * https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/ Some small optimisations may have slipped in as well. --- tests/lib/pysol_tests/scorpion_canMove.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/lib/pysol_tests/scorpion_canMove.py b/tests/lib/pysol_tests/scorpion_canMove.py index aab00015..bb16c012 100644 --- a/tests/lib/pysol_tests/scorpion_canMove.py +++ b/tests/lib/pysol_tests/scorpion_canMove.py @@ -39,7 +39,7 @@ class Mock_S_Game: class MyTests(unittest.TestCase): - def test_canMoveCards(self): + def _calc_Scorpion_stack(self): g = MockGame() stack = Scorpion_RowStack(0, 0, g) cards = [ @@ -51,20 +51,14 @@ class MyTests(unittest.TestCase): c.face_up = True c.item = MockItem() stack.addCard(c) + return stack + + def test_canMoveCards(self): + stack = self._calc_Scorpion_stack() stack.canMoveCards(stack.cards[6:]) self.assertTrue(stack) def test_canMoveCards_non_top(self): - g = MockGame() - stack = Scorpion_RowStack(0, 0, g) - cards = [ - AbstractCard(1000+r*100+s*10, 0, s, r, g) - for s, r in [(2, 5), (3, 7), (2, 7), (2, 0), - (2, 3), (2, 4), (1, 4)] - ] - for c in cards: - c.face_up = True - c.item = MockItem() - stack.addCard(c) + stack = self._calc_Scorpion_stack() self.assertTrue(stack.canMoveCards(stack.cards[4:])) self.assertTrue(stack)