def testUnicodeStringStreamSet(self): ss = StringStream() ns = 'Foo bar baz quux' us = u'Iñtërnâtiônàlizætiøn' # sanity check on regular non-unicode string ss.set(ns) assert (ss.freeze() == ns) # now for the unicode string ss.set(us) assert (ss.freeze() == us.encode('utf-8')) nss = StringStream() nss.thaw(ss.freeze()) assert (ss == nss) assert (nss() == us.encode('utf-8'))
def testUnicodeStringStreamSet(self): ss = StringStream() ns = 'Foo bar baz quux' us = u'Iñtërnâtiônàlizætiøn' # sanity check on regular non-unicode string ss.set(ns) assert(ss.freeze() == ns) # now for the unicode string ss.set(us) assert(ss.freeze() == us.encode('utf-8')) nss = StringStream() nss.thaw(ss.freeze()) assert(ss == nss) assert(nss() == us.encode('utf-8'))
def testString(self): s = StringStream("test") s2 = StringStream(s.freeze()) assert (s == s2) s2 = StringStream("another") assert (s != s2) diff = s.diff(s2) assert (diff == "test") diff2 = s2.diff(s) assert (diff2 == "another") # after the merge, s2 will be "test" assert (not s2.twm(diff, s2)) assert (s == s2) s3 = StringStream("yet one more") # check conflict behavior, this should return True assert (s2.twm(diff2, s3)) # doing a merge to the final value should work diff = s3.diff(s) assert (not s3.twm(diff, s2)) # check string streams that whole None as the value s4 = StringStream(None) assert (s3 != s4) assert (s3 > s4) assert (s4 < s3) # attempt to twm into a string that has a value of None # and a conflicting "other" assert (s4.twm(diff, s2)) # ensure that two None string streams compare equal s5 = StringStream(None) assert (s4 == s5) # ensure that invalid types are handled properly try: StringStream(1) except TypeError, e: assert (str(e) == 'frozen value must be None or a string')
def testString(self): s = StringStream("test") s2 = StringStream(s.freeze()) assert(s == s2) s2 = StringStream("another") assert(s != s2) diff = s.diff(s2) assert(diff == "test") diff2 = s2.diff(s) assert(diff2 == "another") # after the merge, s2 will be "test" assert(not s2.twm(diff, s2)) assert(s == s2) s3 = StringStream("yet one more") # check conflict behavior, this should return True assert(s2.twm(diff2, s3)) # doing a merge to the final value should work diff = s3.diff(s) assert(not s3.twm(diff, s2)) # check string streams that whole None as the value s4 = StringStream(None) assert(s3 != s4) assert(s3 > s4) assert(s4 < s3) # attempt to twm into a string that has a value of None # and a conflicting "other" assert(s4.twm(diff, s2)) # ensure that two None string streams compare equal s5 = StringStream(None) assert(s4 == s5) # ensure that invalid types are handled properly try: StringStream(1) except TypeError, e: assert (str(e) == 'frozen value must be None or a string')