1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Extract a common module/library/header.

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.
This commit is contained in:
Shlomi Fish 2018-10-09 13:08:45 +03:00
parent b142366595
commit 5febb53706
3 changed files with 64 additions and 97 deletions

View file

@ -0,0 +1,62 @@
#! /usr/bin/env python MockItem
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 Shlomi Fish <shlomif@cpan.org>
#
# Distributed under terms of the MIT license.
from pysollib.acard import AbstractCard
import pysollib.stack
"""
"""
class MockItem:
def __init__(self):
pass
def tkraise(self):
return
def addtag(self, nouse):
return
class MockCanvas:
def __init__(self):
self.xmargin = self.ymargin = 50
class MockImages:
def __init__(self):
self.CARDW = self.CARDH = self.CARD_YOFFSET = 50
class MockOpt:
def __init__(self):
self.randomize_place = False
class MockApp:
def __init__(self):
self.images = MockImages()
self.opt = MockOpt()
class MockTalon:
def __init__(self, g):
self.cards = [
AbstractCard(1000+r*100+s*10, 0, s, r, g)
for s in range(4) for r in range(13)]
for c in self.cards:
c.item = MockItem()
def _empty_override(*args):
return True
pysollib.stack.MfxCanvasGroup = _empty_override

View file

@ -1,50 +1,9 @@
# Written by Shlomi Fish, under the MIT Expat License.
import unittest
from pysollib.acard import AbstractCard
from pysollib.hint import FreeCellSolver_Hint, PySolHintLayoutImportError
import pysollib.stack
class MockItem:
def __init__(self):
pass
def tkraise(self):
return
def addtag(self, nouse):
return
class MockCanvas:
def __init__(self):
self.xmargin = self.ymargin = 50
class MockImages:
def __init__(self):
self.CARDW = self.CARDH = self.CARD_YOFFSET = 50
class MockOpt:
def __init__(self):
self.randomize_place = False
class MockApp:
def __init__(self):
self.images = MockImages()
self.opt = MockOpt()
class MockTalon:
def __init__(self, g):
self.cards = [
AbstractCard(1000+r*100+s*10, 0, s, r, g)
for s in range(4) for r in range(13)]
for c in self.cards:
c.item = MockItem()
from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockTalon
class MockGame:
@ -63,13 +22,6 @@ class MockGame:
self.preview = 0
def _empty_override(*args):
return True
pysollib.stack.MfxCanvasGroup = _empty_override
class Mock_S_Game:
def __init__(self):
self.s = MockGame()

View file

@ -4,47 +4,7 @@ import unittest
from pysollib.acard import AbstractCard
import pysollib.stack
from pysollib.games.spider import Scorpion_RowStack
class MockItem:
def __init__(self):
pass
def tkraise(self):
return
def addtag(self, nouse):
return
class MockCanvas:
def __init__(self):
self.xmargin = self.ymargin = 50
class MockImages:
def __init__(self):
self.CARDW = self.CARDH = self.CARD_YOFFSET = 50
class MockOpt:
def __init__(self):
self.randomize_place = False
class MockApp:
def __init__(self):
self.images = MockImages()
self.opt = MockOpt()
class MockTalon:
def __init__(self, g):
self.cards = [
AbstractCard(1000+r*100+s*10, 0, s, r, g)
for s in range(4) for r in range(13)]
for c in self.cards:
c.item = MockItem()
from pysol_tests.common_mocks1 import MockApp, MockCanvas, MockItem, MockTalon
class MockGame:
@ -64,13 +24,6 @@ class MockGame:
self.preview = 0
def _empty_override(*args):
return True
pysollib.stack.MfxCanvasGroup = _empty_override
class Mock_S_Game:
def __init__(self):
self.s = MockGame()