Skip to content

Commit

Permalink
Change project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gyermolenko committed Jan 13, 2019
1 parent 040f0d0 commit 91b2f34
Show file tree
Hide file tree
Showing 107 changed files with 47 additions and 35 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,18 @@ sudo: false

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
# Disabled for now since cause more pain than gain
# - "pypy"
# - "pypy3"
- "3.7"

cache:
- pip

install:
- travis_retry pip install -q codecov
- pip install flake8
- pip install -r requirements-dev.txt

script:
- pytest --doctest-modules behavioral/ creational/ dft/ fundamental/ other/ structural/ # exclude tests/
- pytest --doctest-modules patterns/
- pytest -s -vv --cov=. --log-level=INFO tests/
# Actually run all the scripts, contributing to coverage
- PYTHONPATH=. ./run_all.sh
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
Empty file added patterns/structural/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
-e .
pytest~=4.1
pytest-cov~=2.6
flake8~=3.6
codecov~=2.0
14 changes: 14 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from setuptools import setup

setup(
name='python-patterns',
description='A collection of design patterns and idioms in Python.',
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)
8 changes: 4 additions & 4 deletions tests/test_command.py → tests/behavioral/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import shutil
import unittest
from behavioral.command import MoveFileCommand
from patterns.behavioral.command import MoveFileCommand


class CommandTest(unittest.TestCase):
Expand All @@ -23,8 +23,8 @@ def setUpClass(self):
- get the temporary test directory
- and initializes the command stack.
"""
os.mkdir('tests/test_command')
open('tests/test_command/foo.txt', 'w').close()
os.mkdir('tests/behavioral/test_command')
open('tests/behavioral/test_command/foo.txt', 'w').close()
self.__get_test_directory()
self.command_stack = []
self.command_stack.append(
Expand Down Expand Up @@ -56,4 +56,4 @@ def tearDownClass(self):
"""
Remove the temporary directory /test_command and its content.
"""
shutil.rmtree('tests/test_command')
shutil.rmtree('tests/behavioral/test_command')
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from behavioral.observer import Subject, Data, DecimalViewer, HexViewer
from patterns.behavioral.observer import Subject, Data, DecimalViewer, HexViewer

try:
from unittest.mock import patch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from behavioral.publish_subscribe import Provider, Publisher, Subscriber
from patterns.behavioral.publish_subscribe import Provider, Publisher, Subscriber

try:
from unittest.mock import patch, call
Expand Down
2 changes: 1 addition & 1 deletion tests/test_state.py → tests/behavioral/test_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from behavioral.state import Radio
from patterns.behavioral.state import Radio


class RadioTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from creational.abstract_factory import PetShop, Dog
from patterns.creational.abstract_factory import PetShop, Dog

try:
from unittest.mock import patch
Expand Down
2 changes: 1 addition & 1 deletion tests/test_borg.py → tests/creational/test_borg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from creational.borg import Borg, YourBorg
from patterns.creational.borg import Borg, YourBorg


class BorgTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_builder.py → tests/creational/test_builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from creational.builder import construct_building, House, Flat, ComplexHouse
from patterns.creational.builder import construct_building, House, Flat, ComplexHouse


class TestSimple(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from creational.factory_method import get_localizer
from patterns.creational.factory_method import get_localizer


class TestLocalizer(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lazy.py → tests/creational/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import unittest
from creational.lazy_evaluation import Person
from patterns.creational.lazy_evaluation import Person


class TestDynamicExpanding(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pool.py → tests/creational/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import queue
except ImportError: # python 2.x compatibility
import Queue as queue
from creational.pool import ObjectPool
from patterns.creational.pool import ObjectPool


class TestPool(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from creational.prototype import Prototype, PrototypeDispatcher
from patterns.creational.prototype import Prototype, PrototypeDispatcher


class TestPrototypeFeatures(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import unittest

from dft.constructor_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime
from patterns.dft.constructor_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime

"""
Port of the Java example of "Constructor Injection" in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import unittest

from dft.parameter_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime
from patterns.dft.parameter_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime

"""
Port of the Java example of "Parameter Injection" in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import unittest

from dft.setter_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime
from patterns.dft.setter_injection import TimeDisplay, MidnightTimeProvider, ProductionCodeTimeProvider, datetime

"""
Port of the Java example of "Setter Injection" in
Expand Down
2 changes: 1 addition & 1 deletion tests/test_adapter.py → tests/structural/test_adapter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from structural.adapter import Dog, Cat, Human, Car, Adapter
from patterns.structural.adapter import Dog, Cat, Human, Car, Adapter


class ClassTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bridge.py → tests/structural/test_bridge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from structural.bridge import DrawingAPI1, DrawingAPI2, CircleShape
from patterns.structural.bridge import DrawingAPI1, DrawingAPI2, CircleShape

try:
from unittest.mock import patch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from structural.decorator import TextTag, BoldWrapper, ItalicWrapper
from patterns.structural.decorator import TextTag, BoldWrapper, ItalicWrapper


class TestTextWrapping(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_facade.py → tests/structural/test_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from io import StringIO
except ImportError:
from StringIO import StringIO
from structural.facade import TestRunner, TC1, TC2, TC3
from patterns.structural.facade import TestRunner, TC1, TC2, TC3


class TestRunnerFacilities(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from structural.flyweight import Card
from patterns.structural.flyweight import Card


class TestCard(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_proxy.py → tests/structural/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from time import time
import unittest
from structural.proxy import Proxy, NoTalkProxy
from patterns.structural.proxy import Proxy, NoTalkProxy

if sys.version_info[0] == 2:
from StringIO import StringIO
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hsm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from other.hsm.hsm import (
from patterns.other.hsm.hsm import (
HierachicalStateMachine,
UnsupportedMessageType,
UnsupportedState,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import pytest

from behavioral.visitor import main as visitor_main
from behavioral.visitor import OUTPUT as visitor_output
from behavioral.strategy import main as strategy_main
from behavioral.strategy import OUTPUT as strategy_output
from patterns.behavioral.visitor import main as visitor_main
from patterns.behavioral.visitor import OUTPUT as visitor_output
from patterns.behavioral.strategy import main as strategy_main
from patterns.behavioral.strategy import OUTPUT as strategy_output

@pytest.mark.skipif(sys.version_info < (3,4),
reason="requires python3.4 or higher")
Expand Down

0 comments on commit 91b2f34

Please sign in to comment.