Beispiel #1
0
def test_3lines_clip(output=True):
    config = Config()
    config.text_autoclip_enable = True
    config.text_autoclip_method = C._TEXT_AUTOCLIP_BY_LINE
    config.string_break_enable = True
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    return pp(clip_by_3_lines, output, config=config)
Beispiel #2
0
def test_autoclip_no_room(output=True):
    config = Config()
    # config.debug_level = 9
    config.max_depth = 2
    config.string_break_width = 1
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    return pp(autoclip_no_room, output, config=config)
Beispiel #3
0
def test_autoclip_no_room(output=True):
    config = Config()
    # config.debug_level = 9
    config.max_depth = 2
    config.string_break_width = 1
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    return pp(autoclip_no_room, output, config=config)
Beispiel #4
0
def test_complicate_data(output=True):
    config = Config()
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    config.text_autoclip_enable = False
    res = pp(values, output, config=config)
    res += pp(long_text_in_dict, output, config=config)
    res += pp(long_text_in_list, output, config=config)
    return res
Beispiel #5
0
def test_complicate_data(output=True):
    config = Config()
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    config.text_autoclip_enable = False
    res = pp(values, output, config=config)
    res += pp(long_text_in_dict, output, config=config)
    res += pp(long_text_in_list, output, config=config)
    return res
Beispiel #6
0
def test_sort_of_string(output=True):
    config = Config()
    config.debug_delay = False
    config.str_display_not_prefix_u = False
    config.str_display_not_prefix_b = False
    for sstr in sort_of_string:
        ints = ''
        for e in sstr:
            try:
                ints += '%d ' % ord(e)
            except:
                ints += '%d ' % e
        print('%40s %s %s' % (ints, repr(sstr), len(sstr)))
    return pp(sort_of_string, output, config=config)
Beispiel #7
0
    def test_complicate_data(self):
        config = Config()
        config.string_break_method = C._STRING_BREAK_BY_WIDTH
        config.text_autoclip_enable = False

        ans = u""
        data_path = os.path.join(CUR_SCRIPT_PATH, 'data/all_in_one.txt')
        with codecs.open(data_path, encoding="utf8") as fp:
            ans = fp.read()

        res = pp(values, output=False, config=config)
        res += pp(df.long_text_in_dict, output=False, config=config)
        res += pp(df.long_text_in_list, output=False, config=config)
        self.assertEqual(res, ans)
Beispiel #8
0
def test_sort_of_string(output=True):
    config = Config()
    config.debug_delay = False
    config.str_display_not_prefix_u = False
    config.str_display_not_prefix_b = False
    for sstr in sort_of_string:
        ints = ''
        for e in sstr:
            try:
                ints += '%d ' % ord(e)
            except:
                ints += '%d ' % e
        print('%40s %s %s' % (ints, repr(sstr), len(sstr)))
    return pp(sort_of_string, output, config=config)
Beispiel #9
0
    def test_complicate_data(self):
        config = Config()
        config.string_break_method = C._STRING_BREAK_BY_WIDTH
        config.text_autoclip_enable = False

        ans = u""
        data_path = os.path.join(CUR_SCRIPT_PATH, 
                                 'data/all_in_one.txt')
        with codecs.open(data_path, encoding="utf8") as fp:
            ans = fp.read()

        res = pp(values, output=False, config=config)
        res += pp(df.long_text_in_dict, output=False, config=config)
        res += pp(df.long_text_in_list, output=False, config=config)
        self.assertEqual(res, ans)
Beispiel #10
0
    def test_string(self):
        # string literal
        config = Config()
        config.str_display_not_prefix_u = False
        config.str_display_not_prefix_b = False
        self.assertEqual(pp("plain string", output=False, config=config),
                         "'plain string'\n")

        # unicode string
        s = u'unicode string'
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config),
                             u"u'unicode string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config),
                             u"'unicode string'\n")

        # utf8 string
        s = u'utf8 string'.encode('utf-8')
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config),
                             u"'utf8 string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config),
                             u"b'utf8 string'\n")

        # gb2312 string
        s = u'gb2312 string'.encode('gb2312')
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config),
                             u"'gb2312 string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config),
                             u"b'gb2312 string'\n")

        # unicode special characters string
        s = u'\\'
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"u'\\\\'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"'\\\\'\n")

        # utf8 special characters string
        s = u'\\'.encode("utf8")
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"'\\\\'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"b'\\\\'\n")
Beispiel #11
0
    def test_out_of_range_in_dict(self):
        config = Config()
        config.max_depth = 1

        ans = ""
        rel_path = 'data/out_of_range_in_dict.txt'
        data_path = os.path.join(CUR_SCRIPT_PATH, rel_path)
        with codecs.open(data_path, encoding='utf8') as fp:
            ans = fp.read()
        # delete object id, such as
        # <definition.NormalClassOldStyle object at 0x7f2d9a61bac8>
        ans, _ = re.subn("at 0x[\d\w]+", "", ans)

        res = pp(df.out_of_range_in_dict, output=False, config=config)
        # delete object id, such as
        # <definition.NormalClassOldStyle object at 0x7f2d9a61bac8>
        res, _ = re.subn("at 0x[\d\w]+", "", res)
        
        self.assertEqual(res, ans)
Beispiel #12
0
    def test_out_of_range_in_dict(self):
        config = Config()
        config.max_depth = 1

        ans = ""
        rel_path = 'data/out_of_range_in_dict.txt'
        data_path = os.path.join(CUR_SCRIPT_PATH, rel_path)
        with codecs.open(data_path, encoding='utf8') as fp:
            ans = fp.read()
        # delete object id, such as
        # <definition.NormalClassOldStyle object at 0x7f2d9a61bac8>
        ans, _ = re.subn("at 0x[\d\w]+", "", ans)

        res = pp(df.out_of_range_in_dict, output=False, config=config)
        # delete object id, such as
        # <definition.NormalClassOldStyle object at 0x7f2d9a61bac8>
        res, _ = re.subn("at 0x[\d\w]+", "", res)
        
        self.assertEqual(res, ans)
Beispiel #13
0
    def test_string(self):
        # string literal
        config = Config()
        config.str_display_not_prefix_u = False
        config.str_display_not_prefix_b = False
        self.assertEqual(pp("plain string", output=False, config=config), "'plain string'\n")

        # unicode string
        s = u'unicode string'
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"u'unicode string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"'unicode string'\n")

        # utf8 string
        s = u'utf8 string'.encode('utf-8')
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"'utf8 string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"b'utf8 string'\n")

        # gb2312 string
        s = u'gb2312 string'.encode('gb2312')
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"'gb2312 string'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"b'gb2312 string'\n")

        # unicode special characters string
        s = u'\\'
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"u'\\\\'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"'\\\\'\n")

        # utf8 special characters string
        s = u'\\'.encode("utf8")
        if pyv == 2:
            self.assertEqual(pp(s, output=False, config=config), u"'\\\\'\n")
        else:
            self.assertEqual(pp(s, output=False, config=config), u"b'\\\\'\n")
Beispiel #14
0
def test_3lines_clip(output=True):
    config = Config()
    config.text_autoclip_enable = True
    config.text_autoclip_method = C._TEXT_AUTOCLIP_BY_LINE
    config.string_break_enable = True
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    return pp(clip_by_3_lines, output, config=config)
Beispiel #15
0
DEFAULT_SLEEP   = 5
HALF_SLEEP      = DEFAULT_SLEEP * 0.5
LONGER_SLEEP    = DEFAULT_SLEEP * 1.5
DOUBLE_SLEEP    = DEFAULT_SLEEP * 2

TRUSTAS_NETWORK = E2E_CONFIG['trustas-network']
CC_PATH         = 'github.com/trustas_cc'
CC_NAME         = 'trustas_cc'
CC_VERSION      = '1.0'

logger = logging.getLogger(__name__)

# ----------

# beeprint config
pp_conf = Config()
pp_conf.max_depth = 20
pp_conf.text_autoclip_maxline = 50

# ----------

def global_config():
    """Get configuration from environment variables"""

    global DEFAULT_SLEEP
    global KEEP_NETWORK
    global WIPE_ALL
    global LOCAL_DEPLOY

    if "DEFAULT_SLEEP" in os.environ:
        DEFAULT_SLEEP = int(os.environ["DEFAULT_SLEEP"])
Beispiel #16
0
def test_class_all_repr_disable(output=True):
    config = Config()
    config.instance_repr_enable = False
    return pp(class_repr, output, config=config)
Beispiel #17
0
def test_inline_repr_out_of_range(output=True):
    config = Config()
    config.max_depth = 1
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    config.string_break_width = 40
    return pp(inline_repr, output, config=config)
Beispiel #18
0
def test_class_last_el(output=True):
    config = Config()
    config.instance_repr_enable = False
    rm = ReprMethodClassNewStyle()
    nc = NormalClassNewStyle()
    return pp([rm, nc, rm], output, config=config)
Beispiel #19
0
def test_tuple(output=True):
    config = Config()
    return pp(tuple_testing, output, config=config)
Beispiel #20
0
def test_inline_repr_out_of_range(output=True):
    config = Config()
    config.max_depth = 1
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    config.string_break_width = 40
    return pp(inline_repr, output, config=config)
Beispiel #21
0
def test_tuple_nested(output=True):
    config = Config()
    return pp(tuple_nested, output, config=config)
Beispiel #22
0
def test_dict_ordered_keys(output=True):
    config = Config()
    config.dict_ordered_key_enable = True
    return pp(dict_multi_keys, output, config=config)
Beispiel #23
0
def test_class(output=True):
    config = Config()
    return pp(EmptyClassNewStyle, output, config=config)
Beispiel #24
0
def test_out_of_range_in_dict(output=True):
    config = Config()
    config.max_depth = 1
    return pp(out_of_range_in_dict, output, config=config)
Beispiel #25
0
def test_boundary_break(output=True):
    config = Config()
    config.string_break_method = C._STRING_BREAK_BY_WIDTH
    return pp(v_line_break_boundary, output, config=config)
Beispiel #26
0
def test_inner_class(output=True):
    config = Config()
    return pp(OuterClass, output, config=config)
Beispiel #27
0
def test_class_last_el(output=True):
    config = Config()
    config.instance_repr_enable = False
    rm = ReprMethodClassNewStyle()
    nc = NormalClassNewStyle()
    return pp([rm, nc, rm], output, config=config)