Skip to content

Commit

Permalink
Tidy up test boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Jun 20, 2016
1 parent b402064 commit 84746f0
Show file tree
Hide file tree
Showing 30 changed files with 155 additions and 87 deletions.
5 changes: 5 additions & 0 deletions malcolm/wscomms/wsservercomms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict
import json

Expand Down
7 changes: 7 additions & 0 deletions tests/setup_malcolm_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scanpointgenerator"))

from pkg_resources import require
require("mock", "numpy", "tornado")
7 changes: 0 additions & 7 deletions tests/setup_malcolm_paths.py/util.py

This file was deleted.

8 changes: 6 additions & 2 deletions tests/test_controllers/test_clientcontroller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import MagicMock, patch

# logging
Expand Down
7 changes: 5 additions & 2 deletions tests/test_controllers/test_hellocontroller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import Mock

from malcolm.controllers.hellocontroller import HelloController
Expand Down
12 changes: 4 additions & 8 deletions tests/test_controllers/test_scanpointtickercontroller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import unittest
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.append("/home/mef65357/MappingProject/scanpointgenerator")
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

# mock
from pkg_resources import require
require("mock")
import unittest
from mock import MagicMock, patch
require('numpy')

from malcolm.core.attribute import Attribute
from malcolm.controllers.scanpointtickercontroller import ScanPointTickerController
Expand Down
1 change: 0 additions & 1 deletion tests/test_controllers/util.py

This file was deleted.

8 changes: 6 additions & 2 deletions tests/test_core/test_attribute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import Mock, patch

from malcolm.core.attribute import Attribute
Expand Down
9 changes: 7 additions & 2 deletions tests/test_core/test_attributemeta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from . import util
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

import unittest
from mock import MagicMock

from malcolm.core.attributemeta import AttributeMeta
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_block.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import MagicMock, patch

# module imports
Expand Down
9 changes: 7 additions & 2 deletions tests/test_core/test_clientcomms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import Mock

from malcolm.core.clientcomms import ClientComms, CLIENT_STOP
from malcolm.core.syncfactory import SyncFactory


class TestClientComms(unittest.TestCase):
def test_init(self):
process = Mock()
Expand Down
7 changes: 5 additions & 2 deletions tests/test_core/test_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import MagicMock, call

# module imports
Expand Down
7 changes: 5 additions & 2 deletions tests/test_core/test_loggable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import patch

from malcolm.core.loggable import Loggable
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_mapmeta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import MagicMock, patch, call

from malcolm.core.mapmeta import MapMeta
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_method.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import Mock, patch, call, MagicMock

from malcolm.core.method import Method, takes, returns
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_monitorable.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import Mock

from malcolm.core.monitorable import Monitorable


class TestMonitorable(unittest.TestCase):

def test_init(self):
Expand Down
11 changes: 8 additions & 3 deletions tests/test_core/test_numbermeta.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from . import util
import unittest
from collections import OrderedDict
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict
import numpy as np

import unittest

from malcolm.core.numbermeta import NumberMeta
from malcolm.core.attributemeta import AttributeMeta


class TestNumberMeta(unittest.TestCase):
def test_init_int(self):
nm = NumberMeta("nm", "desc", np.int32)
Expand Down
17 changes: 7 additions & 10 deletions tests/test_core/test_pointgeneratormeta.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import unittest
from collections import OrderedDict
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.append("/home/mef65357/MappingProject/scanpointgenerator")
from scanpointgenerator import Generator
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

# mock
from pkg_resources import require
require("mock")
require("numpy")
from collections import OrderedDict

import unittest
from mock import MagicMock, patch

from scanpointgenerator import Generator
from malcolm.core.pointgeneratormeta import PointGeneratorMeta


Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_process.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict
# import logging
# logging.basicConfig(level=logging.DEBUG)

from . import util
import unittest
from mock import MagicMock

# module imports
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_request.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import MagicMock, patch

from malcolm.core.request import Request
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest
from mock import Mock, MagicMock

from malcolm.core.response import Response
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_servercomms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import Mock

from malcolm.core.servercomms import ServerComms, SERVER_STOP
from malcolm.core.syncfactory import SyncFactory


class TestServerComms(unittest.TestCase):

def setUp(self):
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core/test_stringmeta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from . import util
import unittest

from malcolm.core.stringmeta import StringMeta
from malcolm.core.attributemeta import AttributeMeta
Expand Down
7 changes: 5 additions & 2 deletions tests/test_core/test_syncfactory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest
from mock import patch

# module imports
Expand Down
7 changes: 5 additions & 2 deletions tests/test_core/test_system_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from . import util
import unittest

# logging
# import logging
Expand Down
7 changes: 0 additions & 7 deletions tests/test_core/util.py

This file was deleted.

13 changes: 7 additions & 6 deletions tests/test_wscomms/test_system_wscomms.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import unittest
import time

from . import util
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

import time
# logging
# import logging
# logging.basicConfig(level=logging.DEBUG)

import unittest

# tornado
from pkg_resources import require
require("tornado")
from tornado.websocket import websocket_connect
from tornado import gen
from tornado.ioloop import IOLoop
Expand Down
10 changes: 6 additions & 4 deletions tests/test_wscomms/test_wsclientcomms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from . import util
import unittest
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths

from collections import OrderedDict

from pkg_resources import require
require('tornado')
import unittest
from mock import MagicMock, patch

from malcolm.wscomms.wsclientcomms import WSClientComms
Expand Down

0 comments on commit 84746f0

Please sign in to comment.