Hi, all:
I found comment " self._outrep_summary(rep)" of file terminal.py can
disable this function. However, this can not print all debug infomation.
rep is a TestReport object. Maybe we need to modify it.
2013/2/26 徐荣中 <[email protected]>
> Hi, all:
> when a fail occur, pytest print a lot of error info.
> Could we disable stack info in pytest? We only need error summary
> info like following:
>
> _____________________________________________________________________
> test_ntp
> ______________________________________________________________________
>
> @pytest.mark.webtest
> @pytest.mark.high
> def test_ntp():
> host = snmp.Snmp()
> host.snmp_connect(hostname='172.23.191.53', version=2,
> community='private')
> for ip in ('33.33.1.2', '172.22.1.8'):
> host.snmp_set_check('ntpPrimaryServer.0=' + ip)
> for ntpClientEnabled in ('true', 'false'):
> > host.snmp_set_check('ntpClientEnabled.1=' + ntpClientEnabled)
>
> robot_test.py:15:
>
>
> Thanks!
> Andrew
>
> Following is code and run result:
>
> # vi robot_test.py
>
> #! /usr/bin/env python
> #coding=utf-8
>
> from adva_configure import *
> import snmp
>
> @pytest.mark.webtest
> @pytest.mark.high
> def test_ntp():
> host = snmp.Snmp()
> host.snmp_connect(hostname='172.23.191.53', version=2,
> community='private')
> for ip in ('33.33.1.2', '172.22.1.8'):
> host.snmp_set_check('ntpPrimaryServer.0=' + ip)
> for ntpClientEnabled in ('true', 'false'):
> host.snmp_set_check('ntpClientEnabled.1=' + ntpClientEnabled)
>
>
> def test_something_quick():
>
> assert 1 == 1
> print "\n test_something_quick"
>
> def test_another():
> pass
>
> #pytest.main("robot_test.py -sv")
>
>
>
> [root@SZX-SRV-AUTOMATION python]# py.test -sv robot_test.py
> ================================================================ test
> session starts
> ================================================================
> platform linux2 -- Python 2.6.6 -- pytest-2.3.4 -- /usr/bin/python
> collected 3 items
>
> robot_test.py:7: test_ntp
> ==============================Test Case: test_ntp
>
> python.py:152 robot_test.py:7 test_ntp
>
> robot_test.py:11 snmp.py:538 snmp_connect
> snmp_connect(172.23.191.53, 2, 161, 30000000, 0, private)
>
> robot_test.py:13 snmp.py:875 snmp_set_check
> snmp_set_check(('ntpPrimaryServer.0=33.33.1.2',))
>
> snmp.py:913 snmp.py:808 snmp_set
> snmp_set(('ntpPrimaryServer.0=33.33.1.2',))
>
> snmp.py:914 snmp.py:683 snmp_get
> snmp_get(('ntpPrimaryServer.0=33.33.1.2',))
>
> robot_test.py:13 snmp.py:875 snmp_set_check
> snmp_set_check(('ntpPrimaryServer.0=172.22.1.8',))
>
> snmp.py:913 snmp.py:808 snmp_set
> snmp_set(('ntpPrimaryServer.0=172.22.1.8',))
>
> snmp.py:914 snmp.py:683 snmp_get
> snmp_get(('ntpPrimaryServer.0=172.22.1.8',))
>
> robot_test.py:15 snmp.py:875 snmp_set_check
> snmp_set_check(('ntpClientEnabled.1=true',))
>
> snmp.py:913 snmp.py:808 snmp_set
> snmp_set(('ntpClientEnabled.1=true',))
>
> snmp.py:857 snmp.py:683 snmp_get
> snmp_get(('-s', 'lastSetErrorInformation.0'))
> FAILED
> ==============================End of Test Case
>
> robot_test.py:18: test_something_quick
> ==============================Test Case: test_something_quick
>
> python.py:152 robot_test.py:18 test_something_quick
>
> test_something_quick
> PASSED
> ==============================End of Test Case
>
> robot_test.py:23: test_another
> ==============================Test Case: test_another
>
> python.py:152 robot_test.py:23 test_another
> PASSED
> ==============================End of Test Case
>
>
> =====================================================================
> FAILURES
> ======================================================================
> _____________________________________________________________________
> test_ntp
> ______________________________________________________________________
>
> @pytest.mark.webtest
> @pytest.mark.high
> def test_ntp():
> host = snmp.Snmp()
> host.snmp_connect(hostname='172.23.191.53', version=2,
> community='private')
> for ip in ('33.33.1.2', '172.22.1.8'):
> host.snmp_set_check('ntpPrimaryServer.0=' + ip)
> for ntpClientEnabled in ('true', 'false'):
> > host.snmp_set_check('ntpClientEnabled.1=' + ntpClientEnabled)
>
> robot_test.py:15:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <class 'snmp.Snmp'>, args = ('ntpClientEnabled.1=true',), var_list
> = [<netsnmp.client.Varbind object at 0x99616cc>]
> var_list_txt = [{'expect_value': 'true', 'index': '1', 'name':
> 'ntpClientEnabled.1', 'noid': '.1.3.6.1.4.1.2544.1.12.2.1.10.1', ...}]
>
> @classmethod
> def snmp_set_check(self, *args):
> '''
> *Set and check a list of soids and values. *
>
> --Without '-N' (negative) tag, for example
> snmp_set_check('ecpaControlDuration.1.1.1.1=20'),
> set the ecpaControlDuration.1.1.1.1 to 20 and check result.
> Test fail
> - a, errors from Node: lastSetError
> - b, timeout and other errors from netsnmp.
> - c, Node and index Error etc from adva python snmp library.
> - d, value not equal
>
> --With '-N' (negative) tag, for example
> snmp_set('ecpaControlDuration.1.1.1.1=0, '-N'),
> set the ecpaControlDuration.1.1.1.1 to 20 and Test fails if:
> - a, set ok
> - b, Node Error etc(index not included) from adva python snmp
> library.
> - c, timeout and other errors from netsnmp.
>
> | *Fixed argument* | *type* | *description* |
> | *args | string | one or more string like
> ecpaControlDuration.1.1.1.1=\
> 0, -N, ntpClientEnabled.0=false -c true |
>
> | *optional argument* | *type* | *description* |
> | -N | bool switch | With this tag do Negative check. \
> Without this tag do normal check. |
>
> | *Return type* | *Example* |
> | None | None |
>
> *--Robot Example*
> | snmp_set_check | ntpClientEnabled.0=false -c true | \
> ecpaControlTestType.1.1.24.1=createAndGo | -N |
> | snmp_set_check | ecpaControlTestType.1.1.24.1=createAndGo' |
> '''
> print colors.yellow('\t\tsnmp_set_check({0})'.format(args))
> var_list, var_list_txt = _convert_args_to_list(args,
> return_txt=True)
> > snmp_result = Snmp.snmp_set(*args)
>
> /opt/adva/snmp.py:913:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <class 'snmp.Snmp'>, args = ('ntpClientEnabled.1=true',), var_list
> = [<netsnmp.client.Varbind object at 0x996160c>]
> var_list_txt = [{'expect_value': 'true', 'index': '1', 'name':
> 'ntpClientEnabled.1', 'noid': '.1.3.6.1.4.1.2544.1.12.2.1.10.1', ...}]
> snmp_result = 0
>
> @classmethod
> def snmp_set(self, *args):
> '''
> --Set a list of soids and values.
>
> -Without '-N' (negative) tag, for example
> snmp_set('ecpaControlDuration.1.1.1.1=20'),
> set the ecpaControlDuration.1.1.1.1 to 20 . Test fail if:
> - a, errors from Node: lastSetError
> - b, timeout and other errors from netsnmp.
> - c, Node and index Error etc from adva python snmp library.
>
> -With '-N' (negative) tag, for example
> snmp_set('ecpaControlDuration.1.1.1.1=0, '-N'),
> set the ecpaControlDuration.1.1.1.1 to 20 and Test fails if:
> - a, set ok
> - b, Node Error etc(index not included) from adva python snmp
> library.
> - c, timeout and other errors from netsnmp.
>
> | *Fixed argument* | *type* | *description* |
> | *args | string | one or more string like
> ecpaControlDuration.1.1.1.1=\
> 0, -N |
>
> | *optional argument* | *type* | *description* |
> | -N | bool switch | With this tag do Negative check. \
> Without this tag do normal check. |
>
> | *Return type* | *Example* |
> | None | None |
>
> *--Robot Example*
> | snmp set | ecpaControlDuration.1.1.1.1=0 | -N |
> | snmp set | ecpaControlDuration.1.1.1.1=20 |
> '''
>
> print colors.yellow('\t\tsnmp_set({0})'.format(args))
>
> var_list, var_list_txt = _convert_args_to_list(args,
> return_txt=True)
> snmp_result = Snmp.client.set(var_list)
> # netsnmp python binding return 0 if set fail, return 1 if set ok
> # we need to convert it to the same format as snmp set.
> if snmp_result == 1 and Snmp.reverse:
> output_console_error(
> "SnmpSetNegativeError",
> str(args))
> if snmp_result == 1 and (not Snmp.reverse):
> return
> if snmp_result == 0 and (not Snmp.reverse):
> #print colors.red('\t\t snmp_set Error')
> error_info = Snmp.snmp_get('-s', "lastSetErrorInformation.0")
> #print colors.red('\t\t lastSetErrorInformation: '),
> > assert 0 == 1
> E assert 0 == 1
>
> /opt/adva/snmp.py:859: AssertionError
> ======================================================== 1 failed, 2
> passed in 2.34 seconds
> ========================================================
>
_______________________________________________
Pytest-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pytest-dev