Fixed a test involving writing nicks to csv file.
This commit is contained in:
parent
ab2fe9c87f
commit
02b7e4e967
@ -1,5 +1,6 @@
|
||||
# Yay tests!
|
||||
|
||||
import csv
|
||||
import unittest
|
||||
import newbot
|
||||
import time
|
||||
@ -39,11 +40,16 @@ class TestBotClass(unittest.TestCase):
|
||||
def test_add_nick_to_csv(self):
|
||||
bot = newbot.Bot('test_nicks.csv')
|
||||
bot.add_known_nick('Roger__')
|
||||
self.assertEqual(bot.known_nicks, [['Alice'], ['Bob'], ['Roger']])
|
||||
with open('test_nicks.csv', 'rb') as csv_file:
|
||||
known_nicks = []
|
||||
csv_file_data = csv.reader(csv_file, delimiter=',', quotechar='|')
|
||||
for row in csv_file_data:
|
||||
known_nicks.append(row)
|
||||
self.assertEqual(known_nicks, [['Alice'], ['Bob'], ['Roger']])
|
||||
|
||||
def tearDown(self):
|
||||
with open('test_nicks.csv', 'w') as csv_file:
|
||||
csv_file.write('Alice\nBob')
|
||||
csv_file.write('Alice\nBob\n')
|
||||
|
||||
class TestNewComerClass(unittest.TestCase):
|
||||
|
||||
@ -92,7 +98,7 @@ class TestProcessNewcomers(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
with open('test_nicks.csv', 'w') as csv_file:
|
||||
csv_file.write('Alice\nBob')
|
||||
csv_file.write('Alice\nBob\n')
|
||||
|
||||
#
|
||||
# Not sure how to test check_messages.
|
||||
|
Loading…
Reference in New Issue
Block a user