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. vba Excel连接数据库

    PostgreSql: 第一步 在网上下载postres的驱动程序,之后安装,下载地址:https://www.devart.com/odbc/postgresql/download.html 第二步 ...

  2. 19年最新 Python0基础学习书籍推荐(内涵PDF地址以及书籍源码)

    去年看过一篇文章,是关于18年的最适合0基础学习的书籍,今年,最新的书籍也已经统计出来.书籍的PDF太过于难找,所以很多PDF都找不到. 仅仅只能找到英文版PDF 本文章统计了18.19并做过对比,在 ...

  3. java. util. concurrent. atomic

    一.原子更新基本类型 AtomicInteger AtomicBoolean AtomicLong 二.原子更新数组 AtomicIntegerArray AtomicLongArray Atomic ...

  4. ftp-server(对象存储)

    1.背景 在腾讯云弄了一个对象存储,想通过ftp上传照片 说明连接: 腾讯云:https://cloud.tencent.com/document/product/436/7214 GitHub:ht ...

  5. prometheus+grafana监控mysql

    prometheus+grafana监控mysql 1.安装配置MySQL官方的 Yum Repository(有mysql只需设置监控账号即可) [root@localhost ~]# wget - ...

  6. 西门子软件sinutrain-for-sinumerik-operate-v4.8安装报错的处理

       西门子软件sinutrain-for-sinumerik-operate-v4.8安装报错的处理 安装时报错提示: 原因: 可能缺少某些文件 处理: 安装 海康ivms-4200后,可直接安装西 ...

  7. (二)ActiveMQ之点对点消息实现

    一.点对点消息实现概念 在点对点或队列模型下,一个生产者向一个特定的队列发布消息,一个消费者从该队列中读取消息.这里,生产者知道消费者的队列,并直接将消息发送到消费者的队列.这种模式被概括为:只有一个 ...

  8. 根据xsd文件生成对应的C#类,然后创建对应的xml文件

    首先用xsd文件生产对应的C#类,这个VS已经自带此工单,方法如下: 1. 打开交叉命令行工具 2. 输入如下指令 xsd d:\123.xsd /c /language:C# /outputdir: ...

  9. 微信小程序wx:key以及wx:key=" *this"详解:

    今天写微信小程序无意中看到控制台给出了这样一行提示: 求解百度才知道,给大家分享一下: 1.wx:for定义 官方文档:在组件上使用 wx:for 控制属性绑定一个数组,即可使用数组中各项的数据重复渲 ...

  10. Tensorflow 训练inceptionV4 并移植

    安装brazel    (请使用最新版的brazel  和最新版的tensorflow  ,版本不匹配会出错!!!) 下载bazel-0.23   https://pan.baidu.com/s/1X ...