Created
April 10, 2010 18:03
-
-
Save caike/362203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import TestCase, main | |
import re | |
class WordList(object): | |
def __init__(self, unsorted_words): | |
self.unsorted_words = unsorted_words | |
def unsorted(self): | |
return self.unsorted_words | |
def segment(self): | |
current = self.unsorted_words.pop(0) | |
for word in self.unsorted_words: | |
pass | |
return self.unsorted_words | |
def compare(self, string1, string2): | |
"""docstring for compare""" | |
"compare string1 to string2" | |
"return -1 if string1 is less than string2, 0" | |
"if equal, 1 if greater" | |
tokens1 = re.split('/[0-9]*/', ) | |
return 1 | |
def sorted(self): | |
return self.sorted_words | |
class OrderingTestCase(TestCase): | |
def setUp(self): | |
self.words = ["Alpha A", "Alpha A100", | |
"Alpha A2"] | |
def test_create_list(self): | |
word_list = WordList(self.words) | |
unsorted_results = word_list.unsorted() | |
self.assertEqual(self.words, unsorted_results) | |
def test_make_segments(self): | |
word_list = WordList(self.words) | |
word_segments = word_list.segment() | |
first_segment = word_segments[0] | |
#self.assertEqual('Alpha A', first_segment) | |
def test_compare_greater(self): | |
"""docstring for test_compare""" | |
string1= "Alpha A100" | |
string2= "Alpha A2" | |
word_list = WordList(self.words) | |
self.assertEqual(1, word_list.compare(string1, string2)) | |
def test_compare_less(self): | |
string1 = "Alpha A100" | |
string2 = "Alpha A2" | |
word_list = WordList(self.words) | |
self.assertEqual(-1, word_list.compare(string1, string2)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
watch(/.*py$/) do |f|
system("clear && python main.py")
end