Code formatting cleanups.

这个提交包含在:
Craig Warren
2017-01-26 18:00:51 +00:00
父节点 bdae7ae886
当前提交 4cfdb8f822

查看文件

@@ -5,6 +5,7 @@ import unittest
from contextlib import contextmanager from contextlib import contextmanager
from io import StringIO from io import StringIO
@contextmanager @contextmanager
def captured_output(): def captured_output():
new_out, new_err = StringIO(), StringIO() new_out, new_err = StringIO(), StringIO()
@@ -19,6 +20,7 @@ def captured_output():
from gprMax.input_cmd_funcs import * from gprMax.input_cmd_funcs import *
class My_input_cmd_funcs_test(unittest.TestCase): class My_input_cmd_funcs_test(unittest.TestCase):
def assert_output(self, out, expected_out): def assert_output(self, out, expected_out):
"""helper function""" """helper function"""
@@ -29,29 +31,36 @@ class My_input_cmd_funcs_test(unittest.TestCase):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(0, 0, 0) rx(0, 0, 0)
self.assert_output(out, '#rx: 0 0 0') self.assert_output(out, '#rx: 0 0 0')
def test_rx2(self): def test_rx2(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(0, 1, 2, 'id') rx(0, 1, 2, 'id')
self.assert_output(out, '#rx: 0 1 2 id') self.assert_output(out, '#rx: 0 1 2 id')
def test_rx3(self): def test_rx3(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(2, 1, 0, 'idd', ['Ex']) rx(2, 1, 0, 'idd', ['Ex'])
self.assert_output(out, '#rx: 2 1 0 idd Ex') self.assert_output(out, '#rx: 2 1 0 idd Ex')
def test_rx4(self): def test_rx4(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(2, 1, 0, 'id', ['Ex', 'Ez']) rx(2, 1, 0, 'id', ['Ex', 'Ez'])
self.assert_output(out, '#rx: 2 1 0 id Ex Ez') self.assert_output(out, '#rx: 2 1 0 id Ex Ez')
def test_rx4(self): def test_rx4(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(2, 1, 0, 'id', ['Ex', 'Ez']) rx(2, 1, 0, 'id', ['Ex', 'Ez'])
self.assert_output(out, '#rx: 2 1 0 id Ex Ez') self.assert_output(out, '#rx: 2 1 0 id Ex Ez')
def test_rx_rotate_exception(self): def test_rx_rotate_exception(self):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='x', rotate90origin=(1, 1)) # no dxdy given rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='x', rotate90origin=(1, 1)) # no dxdy given
def test_rx_rotate_success(self): def test_rx_rotate_success(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='x', rotate90origin=(1, 1), dxdy=(0, 0)) rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='x', rotate90origin=(1, 1), dxdy=(0, 0))
self.assert_output(out, '#rx: 1 2 0 id Ex Ez') # note: x, y swapped self.assert_output(out, '#rx: 1 2 0 id Ex Ez') # note: x, y swapped
def test_rx_rotate_success2(self): def test_rx_rotate_success2(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='y', rotate90origin=(1, 1), dxdy=(0, 0)) rx(2, 1, 0, 'id', ['Ex', 'Ez'], polarisation='y', rotate90origin=(1, 1), dxdy=(0, 0))
@@ -61,6 +70,7 @@ class My_input_cmd_funcs_test(unittest.TestCase):
with captured_output() as (out, err): with captured_output() as (out, err):
src_steps() src_steps()
self.assert_output(out, '#src_steps: 0 0 0') self.assert_output(out, '#src_steps: 0 0 0')
def test_src_steps2(self): def test_src_steps2(self):
with captured_output() as (out, err): with captured_output() as (out, err):
src_steps(42, 43, 44.2) src_steps(42, 43, 44.2)
@@ -70,6 +80,7 @@ class My_input_cmd_funcs_test(unittest.TestCase):
with captured_output() as (out, err): with captured_output() as (out, err):
rx_steps() rx_steps()
self.assert_output(out, '#rx_steps: 0 0 0') self.assert_output(out, '#rx_steps: 0 0 0')
def test_rx_steps2(self): def test_rx_steps2(self):
with captured_output() as (out, err): with captured_output() as (out, err):
rx_steps(42, 43, 44.2) rx_steps(42, 43, 44.2)