1 Star 1 Fork 0

flytassel/基于Python的文本计数统计

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
python_test.py 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
Chen Zhicheng 提交于 2022-11-02 21:35 . v0.3 项目完成扩展功能
# _*_ coding:utf-8 _*_
import pytest
import count
# import GUI
def test_passing():
assert (1, 2, 3) == (1, 2, 3) # 默认样例,肯定会通过的
# def test_file_name(): # 测试
# GUI.create_window()
# filename = GUI.click_button_open()#好像无法返回值,这个无法测试
# expected_filename = r"C:\Users\feemo\Documents\PycharmProjects\Python_word_count\欧路简版.txt"
# assert filename == expected_filename # 默认样例,肯定会通过的
def test_hangshu(): # 针对行数的特定文件的测试
mode = '-h'
file_name = '欧路简版.txt' # 行数一共6行
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result == 12, "测试失败"
# print("测试通过")
def test_character(): # 针对字符数的特定文件的测试
mode = '-c'
file_name = '欧路简版.txt' # 字符数为320
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result == 476, "测试失败"
# print("测试通过")
def test_word(): # 针对字符数的特定文件的测试
mode = '-w'
file_name = '欧路简版.txt' # 单词数为46
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result == 122
def test_blanklines(): # 针对字符数的特定文件的测试
mode = '-b'
file_name = '欧路简版.txt' # 空行为2
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result == 2
def test_codelines(): # 针对字符数的特定文件的测试
mode = '-code'
file_name = '欧路简版.txt' # 代码行为7
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result ==7
def test_commentlines(): # 针对字符数的特定文件的测试
mode = '-#'
file_name = '欧路简版.txt' # 注释行为7
helper = count.CountHelper(mode, file_name)
result = helper.choose()
assert result ==1
# if __name__ == '__main__':
# mode, file_name = count.file()
# test_addition(mode,file_name)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flytassel/Python_word_count.git
git@gitee.com:flytassel/Python_word_count.git
flytassel
Python_word_count
基于Python的文本计数统计
master

搜索帮助