• Kirill Smelkov's avatar
    golang_str: tests: Deep replacer · 2c20c055
    Kirill Smelkov authored
    deepReplace returns object's clone with replacing all internal objects
    selected by predicate via provided replacement function. We will use
    this functionality in the following patches to organize testing of
    bstr/ustr methods: a method would be first invoked on regular str, and
    then on bstr/ustr and the result will be compared against each other.
    The results are usually different, because e.g. u'a b c'.split() returns
    [u'a', u'b', u'c'] while b('a b c').split() should return
    [b('a'), b('b'), b('c')]. We want to make sure that the second result is
    exactly the first result with all instances of unicode replaced by bstr.
    That's where deep replacer will be used.
    
    The deep replacement itself is implemented via pickle reduce/rebuild
    protocol: we unassemble and reconstruct objects. And while an object is
    unassembled, we try to apply the replacement recursively. Since this is
    not so trivial functionality, it itself also comes with a test.
    2c20c055
golang_str_test.py 47 KB