Skip to content

Commit

Permalink
DRY _tabs method in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Sep 26, 2015
1 parent 9c21835 commit fff458d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
11 changes: 3 additions & 8 deletions tests/openwrt/test_network.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import unittest

from netjsonconfig import OpenWrt

from .utils import _TabsMixin


class TestNetworkRendererer(unittest.TestCase):
class TestNetworkRendererer(unittest.TestCase, _TabsMixin):
"""
tests for backends.openwrt.renderers.NetworkRendererer
"""
def _tabs(self, string):
"""
replace 4 spaces with 1 tab
"""
return string.replace(' ', '\t')

def test_loopback(self):
o = OpenWrt({
"type": "DeviceConfiguration",
Expand Down
11 changes: 3 additions & 8 deletions tests/openwrt/test_system.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import unittest

from netjsonconfig import OpenWrt

from .utils import _TabsMixin


class TestSystemRendererer(unittest.TestCase):
class TestSystemRendererer(unittest.TestCase, _TabsMixin):
"""
tests for backends.openwrt.renderers.SystemRendererer
"""
def _tabs(self, string):
"""
replace 4 spaces with 1 tab
"""
return string.replace(' ', '\t')

def test_system(self):
o = OpenWrt({
"type": "DeviceConfiguration",
Expand Down
11 changes: 3 additions & 8 deletions tests/openwrt/test_wireless.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import unittest

from netjsonconfig import OpenWrt

from .utils import _TabsMixin


class TestWirelessRendererer(unittest.TestCase):
class TestWirelessRendererer(unittest.TestCase, _TabsMixin):
"""
tests for backends.openwrt.renderers.WirelessRendererer
"""
def _tabs(self, string):
"""
replace 4 spaces with 1 tab
"""
return string.replace(' ', '\t')

def test_radio(self):
o = OpenWrt({
"type": "DeviceConfiguration",
Expand Down
10 changes: 10 additions & 0 deletions tests/openwrt/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class _TabsMixin(object):
"""
mixin that adds _tabs method to test classes
"""
def _tabs(self, string):
"""
replace 4 spaces with 1 tab
"""
return string.replace(' ', '\t')

0 comments on commit fff458d

Please sign in to comment.