<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = '7sDream'

import os
import shutil
from zhihu import ZhihuClient, ActType


def test_question():
    url = 'http://www.zhihu.com/question/24825703'
    question = client.question(url)

    # 获取该问题的详细描述
    print(question.title)
    # 亲密关系之间要说「谢谢」吗？

    # 获取该问题的详细描述
    print(question.details)
    # 从小父母和大家庭里，.......什么时候不该说"谢谢”？？

    # 获取回答个数
    print(question.answer_num)
    # 630

    # 获取关注该问题的人数
    print(question.follower_num)
    # 4326

    # 获取关注问题的用户
    for _, follower in zip(range(10), question.followers):
        print(follower.name)
    # <NAME>
    # 熊猫
    # <NAME>
    # ...

    # 获取该问题所属话题
    print(question.topics)
    # ['心理学', '恋爱', '社会', '礼仪', '亲密关系']

    # 获取排名第一的回答的点赞数
    print(question.top_answer.upvote_num)
    # 197

    # 获取排名前十的十个回答的点赞数
    for answer in question.top_i_answers(10):
        print(answer.author.name, answer.upvote_num, answer.author.motto)
    # 49
    # 89
    # 425
    # ...


def test_answer():
    url = 'http://www.zhihu.com/question/24825703/answer/30975949'
    answer = client.answer(url)

    # 获取答案url
    print(answer.url)<commit_msg>add tests<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = '7sDream'

import os
import shutil
from datetime import datetime

from zhihu import ZhihuClient, ActType


def test_question():
    url = 'http://www.zhihu.com/question/24825703'
    question = client.question(url)

    # 获取该问题的详细描述
    print(question.title)
    # 亲密关系之间要说「谢谢」吗？

    # 获取该问题的详细描述
    print(question.details)
    # 从小父母和大家庭里，.......什么时候不该说"谢谢”？？

    # 获取回答个数
    print(question.answer_num)
    # 630

    # 获取关注该问题的人数
    print(question.follower_num)
    # 4326

    # 获取关注问题的用户
    for _, follower in zip(range(10), question.followers):
        print(follower.name)
    # <NAME>
    # 熊猫
    # <NAME>
    # ...

    # 获取该问题所属话题
    print(question.topics)
    # ['心理学', '恋爱', '社会', '礼仪', '亲密关系']

    # 获取排名第一的回答的点赞数
    print(question.top_answer.upvote_num)
    # 197

    # 获取排名前十的十个回答的点赞数
    for answer in question.top_i_answers(10):
        print(answer.author.name, answer.upvote_num, answer.author.motto)
    # 49
    # 89
    # 425
    # ...

    # 获取提问时间
    ctime = question.creation_time
    print(ctime)
    assert ctime == datetime.strptime('2014-08-12 17:58:07', "%Y-%m-%d %H:%M:%S")

    # 获取最后编辑时间
    last_edit_time = question.last_edit_time
    print(last_edit_time)
    assert last_edit_time >= datetime.strptime('2015-04-01 00:39:21', "%Y-%m-%d %H:%M:%S")


def test_answer():
    url = 'http://www.zhihu.com/question/24825703/answer/30975949'
    answer = client.answer(url)

    # 获取答案url
    print(answer.url)
{'fraction_non_alphanumeric': 0.1443830570902394, 'fraction_numerical': 0.04567219152854512, 'mean_word_length': 2.6456375838926176, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '465959', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1319, 'n_words': 168}