Pytest编写测试函数

一个规范的测试方法一定带有断言,在使用pytest时,可以直接使用Python自带的assert关键字

Pytest允许在assert关键字添加任意表达式,表达式的值通过bool转换后等于False则表示断言失败,测试用例执行失败;如果等于True则表示断言成功,测试用例执行成功。

重写assertpytest

可以重写assert关键字,它可以截断对原生assert的调用,替换为pytest定义的assert,从而展示更详细的信息和细节。

from collections import namedtuple
Task = namedtuple('Task', ['summary','owner','done','id'])
# __new__.__defaults__创建默认的Task对象
Task.__new__.__defaults__ = (None, None, False, None) import pytest def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
assert t1 == t2 def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
assert t1_dict == t2_dict

执行结果如下:

E:\Programs\Python\Python_Pytest\TestScripts>pytest test_three.py
======================= test session starts ==========================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items test_three.py FF [100%] ===================== FAILURES ==================================
_____________________ test_task_equality _______________________________ def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Use -v to get the full diff test_three.py:14: AssertionError
-------------------- Captured stdout call ----------------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
________________ test_dict_equal ______________________________ def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
> assert t1_dict == t2_dict
E AssertionError: assert OrderedDict([...('id', None)]) == OrderedDict([(...('id', None)])
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'owner': 'okken'} != {'owner': 'okkem'}
E Use -v to get the full diff test_three.py:22: AssertionError
------------------------------- Captured stdout call --------------------------------------------
OrderedDict([('summary', 'make sandwich'), ('owner', 'okken'), ('done', False), ('id', None)])
OrderedDict([('summary', 'make sandwich'), ('owner', 'okkem'), ('done', False), ('id', None)])
================ 2 failed in 0.20 seconds=============================

加上参数-v,执行结果如下:

E:\Programs\Python\Python_Pytest\TestScripts>pytest test_three.py -v
================= test session starts ===============================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- c:\python37\python.exe
cachedir: .pytest_cache
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items test_three.py::test_task_equality FAILED [ 50%]
test_three.py::test_dict_equal FAILED [100%] ==================== FAILURES =========================
____________________ test_task_equality ________________________ def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Full diff:
E - Task(summary='sit there', owner='brain', done=False, id=None)
E ? ^^^ ^^^ ^^^^
E + Task(summary='do something', owner='okken', done=False, id=None)
E ? +++ ^^^ ^^^ ^^^^ test_three.py:14: AssertionError
-------------------- Captured stdout call -----------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
____________________ test_dict_equal ________________________________ def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
> assert t1_dict == t2_dict
E AssertionError: assert OrderedDict([...('id', None)]) == OrderedDict([(...('id', None)])
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'owner': 'okken'} != {'owner': 'okkem'}
E Full diff:
E OrderedDict([('summary', 'make sandwich'),
E - ('owner', 'okken'),
E ? ^...
E
E ...Full output truncated (5 lines hidden), use '-vv' to show test_three.py:22: AssertionError
--------------------------- Captured stdout call --------------------------------
OrderedDict([('summary', 'make sandwich'), ('owner', 'okken'), ('done', False), ('id', None)])
OrderedDict([('summary', 'make sandwich'), ('owner', 'okkem'), ('done', False), ('id', None)])
================= 2 failed in 0.13 seconds ============================

预期异常

"""
在Task项目的API中,有几个地方可能抛出异常
def add(task): # type:(Task) ->int
def get(task_id): # type:(int) ->Task
def list_tasks(owner=None): # type:(str|None) ->list of task
def count(): # type:(None) ->int
def update(task_id, task): # type:(int, Task) ->None
def delete(task_id): # type:(int) ->None
def delete_all(): # type:() ->None
def unique_id(): # type:() ->int
def start_tasks_db(db_path, db_type): # type:(str, str) ->None
def stop_tasks_db(): # type:() ->None
""" import pytest
import tasks def test_add_raises():
with pytest.raises(TypeError):
tasks.add(task='no a Task object') """
测试用例中有with pytest.raise(TypeError)生命,意味着无论with结构中的内容是什么
都至少会发生TypeError异常,如果测试通过,说明确实发生了我们预期TypeError,如果抛出的是其他类型的异常
则与我们预期的异常不一致,测试用例执行失败
""" def test_start_tasks_db_raises():
with pytest.raises(ValueError) as excinfo:
tasks.start_tasks_db('some/great/path', 'mysql')
exception_msg = excinfo.value.args[0]
assert exception_msg == "db_type must be a 'tiny' or 'mongo' "

测试函数的标记

from collections import namedtuple
import pytest
Task = namedtuple('Task', ['summary','owner','done','id'])
# __new__.__defaults__创建默认的Task对象
Task.__new__.__defaults__ = (None, None, False, None) @pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
assert t1 == t2 @pytest.mark.dict
@pytest.mark.smoke
def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
assert t1_dict == t2_dict

执行结果如下:

E:\Programs\Python\Python_Pytest\TestScripts>pytest -v -m 'smoke' test_five.py
================ test session starts =====================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- c:\python37\python.exe
cachedir: .pytest_cache
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items test_five.py::test_task_equality FAILED [ 50%]
test_five.py::test_dict_equal FAILED [100%] =================== FAILURES ==============================
______________ test_task_equality _________________________
@pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Full diff:
E - Task(summary='sit there', owner='brain', done=False, id=None)
E ? ^^^ ^^^ ^^^^
E + Task(summary='do something', owner='okken', done=False, id=None)
E ? +++ ^^^ ^^^ ^^^^ test_five.py:14: AssertionError
----------------------- Captured stdout call ----------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
___________________ test_dict_equal ___________________
@pytest.mark.dict
@pytest.mark.smoke
def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
> assert t1_dict == t2_dict
E AssertionError: assert OrderedDict([...('id', None)]) == OrderedDict([(...('id', None)])
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'owner': 'okken'} != {'owner': 'okkem'}
E Full diff:
E OrderedDict([('summary', 'make sandwich'),
E - ('owner', 'okken'),
E ? ^...
E
E ...Full output truncated (5 lines hidden), use '-vv' to show test_five.py:24: AssertionError
------------------------ Captured stdout call -------------------------------
OrderedDict([('summary', 'make sandwich'), ('owner', 'okken'), ('done', False), ('id', None)])
OrderedDict([('summary', 'make sandwich'), ('owner', 'okkem'), ('done', False), ('id', None)])
================ warnings summary =========================
c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo? You can register custom marks to avoi
d this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.dict - is this a typo? You can register custom marks to avoid
this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, -- Docs: https://docs.pytest.org/en/latest/warnings.html
============== 2 failed, 2 warnings in 0.22 seconds =======================

在命令行执行使用了 -m marker_name参数,pytest在执行时会自动寻找被标记为marker_name的测试方法去执行,同时-m还支持and、or、not关键字,如下方式:

E:\Programs\Python\Python_Pytest\TestScripts>pytest -v -m "smoke and not dict" test_five.py
=========== test session starts ==============================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- c:\python37\python.exe
cachedir: .pytest_cache
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items / 1 deselected / 1 selected test_five.py::test_task_equality FAILED [100%] =============== FAILURES ==================
_______________ test_task_equality ____________________________ @pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Full diff:
E - Task(summary='sit there', owner='brain', done=False, id=None)
E ? ^^^ ^^^ ^^^^
E + Task(summary='do something', owner='okken', done=False, id=None)
E ? +++ ^^^ ^^^ ^^^^ test_five.py:14: AssertionError
--------------- Captured stdout call ------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
================ warnings summary ====================
c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo? You can register custom marks to avoi
d this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.dict - is this a typo? You can register custom marks to avoid
this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, -- Docs: https://docs.pytest.org/en/latest/warnings.html
============= 1 failed, 1 deselected, 2 warnings in 0.14 seconds ===========

跳过测试

from collections import namedtuple
import pytest
Task = namedtuple('Task', ['summary','owner','done','id'])
# __new__.__defaults__创建默认的Task对象
Task.__new__.__defaults__ = (None, None, False, None) @pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
assert t1 == t2 @pytest.mark.dict
@pytest.mark.smoke
@pytest.mark.skip(reason="跳过原因你不知道吗?")
def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
assert t1_dict == t2_dict

执行结果:

E:\Programs\Python\Python_Pytest\TestScripts>pytest -v test_five.py
=============== test session starts ===================================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- c:\python37\python.exe
cachedir: .pytest_cache
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items test_five.py::test_task_equality FAILED [ 50%]
test_five.py::test_dict_equal SKIPPED [100%] ============== FAILURES ==================================
__________________ test_task_equality _______________________________ @pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Full diff:
E - Task(summary='sit there', owner='brain', done=False, id=None)
E ? ^^^ ^^^ ^^^^
E + Task(summary='do something', owner='okken', done=False, id=None)
E ? +++ ^^^ ^^^ ^^^^ test_five.py:14: AssertionError
------------------ Captured stdout call --------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
=========== warnings summary ==============================
c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo? You can register custom marks to avoi
d this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.dict - is this a typo? You can register custom marks to avoid
this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, -- Docs: https://docs.pytest.org/en/latest/warnings.html
=========== 1 failed, 1 skipped, 2 warnings in 0.21 seconds ================

从测试结果中我们看到,测试用例test_five.py::test_dict_equal SKIPPED 被跳过了,然而跳过原因并没有如期的展示出来,可以使用参数-rs来展示跳过原因,如下方式:

E:\Programs\Python\Python_Pytest\TestScripts>pytest -rs test_five.py
===================== test session starts ===========================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, emoji-0.2.0, allure-pytest-2.6.3
collected 2 items test_five.py Fs [100%] ============ FAILURES ====================================
__________________________ test_task_equality _______________________
@pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
> assert t1 == t2
E AssertionError: assert Task(summary=...alse, id=None) == Task(summary='...alse, id=None)
E At index 0 diff: 'sit there' != 'do something'
E Use -v to get the full diff test_five.py:14: AssertionError
-------------------- Captured stdout call ----------------------------------
Task(summary='sit there', owner='brain', done=False, id=None)
Task(summary='do something', owner='okken', done=False, id=None)
========== warnings summary ====================
c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo? You can register custom marks to avoi
d this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.dict - is this a typo? You can register custom marks to avoid
this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning, -- Docs: https://docs.pytest.org/en/latest/warnings.html
============ short test summary info ====================
SKIPPED [1] test_five.py:17: 跳过原因你不知道吗?
========== 1 failed, 1 skipped, 2 warnings in 0.14 seconds =================

还可以给跳过添加理由,例如当selenium版本是1.0.4的时候跳过

from collections import namedtuple
import pytest
import selenium
Task = namedtuple('Task', ['summary','owner','done','id'])
# __new__.__defaults__创建默认的Task对象
Task.__new__.__defaults__ = (None, None, False, None) @pytest.mark.smoke
def test_task_equality():
t1 = Task('sit there', 'brain')
t2 = Task('do something', 'okken')
print(t1)
print(t2)
assert t1 == t2 @pytest.mark.dict
@pytest.mark.smoke
@pytest.mark.skipif(selenium.__version__ == '1.0.4', reason="跳过原因你不知道吗?")
def test_dict_equal():
t1_dict = Task('make sandwich', 'okken')._asdict()
t2_dict = Task('make sandwich', 'okkem')._asdict()
print(t1_dict)
print(t2_dict)
assert t1_dict == t2_dict

运行测试子集

运行单个目录,只需要将目录作为pytest的参数即可

pytest -v test/func  --tb=no
1
运行单个测试函数,只需要在文件名后添加::符号和函数名 pytest -v test/func/test_five.py::test_dict_equal
1
运行单个测试类,与运行单个测试函数类似,在文件名后添加::符号和类名 pytest -v test/func/test_five.py::Test_Update
1
运行单个测试类中的测试方法,在文件名后添加::符号和类名然后再跟::符号和函数名 pytest -v test/func/test_five.py::Test_Update::test_dict_equal









Pytest编写测试函数的更多相关文章

  1. 【PYTEST】第二章编写测试函数

    知识点: assert 测试函数标记 跳过测试 标记预期失败的测试用例 1. asseet 返回的都是布尔值,等于False(F) 就是失败, assert 有很多 assert something ...

  2. python+pytest接口自动化(12)-自动化用例编写思路 (使用pytest编写一个测试脚本)

    经过之前的学习铺垫,我们尝试着利用pytest框架编写一条接口自动化测试用例,来厘清接口自动化用例编写的思路. 我们在百度搜索天气查询,会出现如下图所示结果: 接下来,我们以该天气查询接口为例,编写接 ...

  3. python+pytest接口自动化(11)-测试函数、测试类/测试方法的封装

    前言 在python+pytest 接口自动化系列中,我们之前的文章基本都没有将代码进行封装,但实际编写自动化测试脚本中,我们都需要将测试代码进行封装,才能被测试框架识别执行. 例如单个接口的请求代码 ...

  4. pytest学习笔记(二)

    继续文档的第二章 (一)pytest中可以在命令行中静态/动态添加option,这里没什么好讲的,略过... 这里面主要讲下如何试用skip/xfail,还有incremental(包含一些列的测试步 ...

  5. Pytest高级进阶之Fixture

    From: https://www.cnblogs.com/feiyi211/p/6626314.html 一. fixture介绍 fixture是pytest的一个闪光点,pytest要精通怎么能 ...

  6. iOS自动化探索(六)自动化测试框架pytest - fixtures

    Fixture介绍 fixture是pytest特有的功能,它用pytest.fixture标识,定义在函数前面.在编写测试函数的时候,可以将此函数名称做为传入参数,pytest将会以依赖注入方式,将 ...

  7. 《带你装B,带你飞》pytest成魔之路4 - fixture 之大解剖

    1. 简介 fixture是pytest的一个闪光点,pytest要精通怎么能不学习fixture呢?跟着我一起深入学习fixture吧.其实unittest和nose都支持fixture,但是pyt ...

  8. pytest学习纪要123-针对经常用到的内容详实记录

    pytest123 本文主要参考:https://www.cnblogs.com/yoyoketang/tag/pytest 如有侵权,请站内联系我 目录 pytest123 1.setup和tear ...

  9. 技术面试没过,居然是没有用pytest测试框架

    1.引言 我有一个朋友是做Python自动化测试的.前几天他告诉我去参加一个大厂面试被刷了. 我问他是有没有总结被刷下来的原因.他说面试官问了一些 pytest 单元测试框架相关的知识,包括什么插件系 ...

随机推荐

  1. 高级UI-RecyclerView简单使用

    RecyclerView从Android 5.0开始引入,用以替代ListView.GridView控件,RecyclerView的存在,使得控件的耦合度更低,在ListView中需要使用ViewHo ...

  2. JWT(JSON Web Tokens)操作帮助类

    载荷实体: /// <summary> /// JWT载荷实体 /// </summary> public sealed class JWTPlayloadInfo { /// ...

  3. Spring 多对对实体

    package com.wangshenghua.entity; import java.io.Serializable; import java.util.Set; import javax.per ...

  4. Jenkins+MSbuild+SVN实现快速搭建.net持续集成环境(构建、编辑、部署到服务器)

    Jenkins是一个可扩展的持续集成引擎,Jenkins非常易于安装和配置,简单易用,下面开始搭建.net持续集成环境 Jenkins和SVN安装这里就不介绍了 一.准备工作 1.Jenkins中系统 ...

  5. Leetcode739 - Daily Temperatures

    题目描述 Leetcode 739 本题考察了栈的使用.题目输入是一段温度值列表,然后返回一个列表.这个列表包含了输入列表中每一天还有多少天温度升高.如果未来没有升高的情况,则输入 0. # Exam ...

  6. js修改css属性值

    推荐用dom.style.setProperty('属性','属性值'); 例如: $("#id")[0].style.setProperty('margin-top','1px' ...

  7. opencv根据摄像头名称获取索引值

    OpenCV的VideoCapture是一个视频读取与解码的API接口,支持各种视频格式.网络视频流.摄像头读取. 针对一般摄像头的读取,opencv为了实现跨平台读取摄像头时是使用的摄像头索引, V ...

  8. [转帖]Greenplum: 基于PostgreSQL的分布式数据库内核揭秘(下篇)

    Greenplum: 基于PostgreSQL的分布式数据库内核揭秘(下篇) http://www.postgres.cn/v2/news/viewone/1/454 原作者:姚延栋 创作时间:201 ...

  9. asp.net mvc抓取微信文章里面所有的图片

    /// <summary> /// 下载指定URL下的所有图片 /// </summary> public class WebPageImage { /// <summa ...

  10. Http中的同步请求和异步请求

    最近在上springmvc的JSON数据交换的时候,老师下课提了一个课后问题:什么是异步请求?什么是同步请求?我想大部分同学听到这个问题的时候应该和我一样不知所云.现在,给大家分享一篇关于同步请求和异 ...