示例#1
0
def test_get_base_path():
    actual_base_path = r'G:\Projects\Python_Projects\python-base\spider\pixiv\crawler\result'
    path_name = 'collect'
    u_unittest.assert_eq(os.path.join(actual_base_path, path_name), get_base_path(path_name))

    # 包含子路径的情况
    path_name = r'collect\ignore'
    u_unittest.assert_eq(os.path.join(actual_base_path, path_name), get_base_path(path_name))
示例#2
0
def test_get_image():
    image_path = r'H:\Pictures\动漫插画\初音未来-miku\comic_louli (3366).png'
    width, height = 1366, 768
    image = get_image(image_path)
    u_unittest.assert_eq(width, image.width)
    u_unittest.assert_eq(height, image.height)

    image = get_image(image_path, resize_size=(200, 200))
    u_unittest.assert_eq(200, image.width)
    u_unittest.assert_eq(200, image.height)

    image = get_image(image_path, thumbnail_size=(200, 200))
    u_unittest.assert_eq(200, image.width)
示例#3
0
def test_get_illust_id():
    u_unittest.assert_eq(42344051, get_illust_id(r'G:\Projects\illusts\8000-9000\42344051_p0-3日で消えり.jpg'))
    u_unittest.assert_eq(42344051, get_illust_id(r'42344051_p0-3日で消えり.jpg'))
示例#4
0
def test_m_get():
    u_unittest.assert_eq(u_file.m_get({'a': {'b': {'c': 1}}}, 'a.b.c', 2), 1)
    u_unittest.assert_eq(u_file.m_get({'a': {'b': {'c': 1}}}, 'a.b.d', 2), 2)
示例#5
0
def test_get_file_name_from_url():
    url = 'https://files.yande.in/image/yande.re%20485154%20bra%20breasts%20nipples%20nurse%20thighhighs.png'
    u_unittest.assert_eq(
        'yande.re 485154 bra breasts nipples nurse thighhighs.png',
        u_file.get_file_name_from_url(url))
示例#6
0
def test_read_write_file():
    content = '--something--'
    file_path = r'cache\test.dat'
    file_path = os.path.abspath(file_path)
    u_file.write_content(file_path, content)
    u_unittest.assert_eq(content, u_file.read_content(file_path))
def test_get_10_20():
    u_unittest.assert_eq(8, get_10_20(8)[0])
    u_unittest.assert_eq(10, get_10_20(18)[0])
    u_unittest.assert_eq(3000, get_10_20(3999)[0])
示例#8
0
def test_get_color_by_hsv():
    u_unittest.assert_eq('red', get_color_by_hsv(5))
    u_unittest.assert_eq('red', get_color_by_hsv(160))
    u_unittest.assert_eq('orange', get_color_by_hsv(25))
示例#9
0
def test_get_illust_id():
    file = r'G:\Projects\Python_Projects\python-base\spider\pixiv\crawler\result\ignore\small\56765988_p0-5' \
           r'年後神楽-沖田総悟-沖神-神楽-神沖-銀魂-銀魂10000users入り.jpg'
    illust_id = get_illust_id(file)
    u_unittest.assert_eq(56765988, illust_id)