Skip to content

Commit

Permalink
Refactor: convert to test class to make the per method fixture easier…
Browse files Browse the repository at this point in the history
… to use
  • Loading branch information
fr2d9y2 authored and fr2d9y2 committed Apr 6, 2017
1 parent 1271062 commit 4712b10
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions mars-rover/test/test_rover.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from nose.tools import *
import rover

def setup():
global r
r = rover.Rover(10, 21, 'N')
class TestRover:

def test_initial_x():
assert_equal(10, r.x)
def setup(self):
global r
r = rover.Rover(10, 21, 'N')

def test_initial_y():
assert_equal(21, r.y)
def test_initial_x(self):
assert_equal(10, r.x)

def test_initial_orientation():
assert_equal('N', r.orientation)
def test_initial_y(self):
assert_equal(21, r.y)

def test_move_f():
r.move(list("f"))
assert_equal(22, r.y)
assert_equal(10, r.x)
def test_initial_orientation(self):
assert_equal('N', r.orientation)

@with_setup(setup)
def test_move_b():
r.move(list("b"))
assert_equal(10, r.x)
assert_equal(20, r.y)
def test_move_f(self):
r.move(list("f"))
assert_equal(22, r.y)
assert_equal(10, r.x)

def test_move_b(self):
r.move(list("b"))
assert_equal(10, r.x)
assert_equal(20, r.y)

0 comments on commit 4712b10

Please sign in to comment.