~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to lib/subunit/python/subunit/tests/test_subunit_stats.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  subunit: extensions to python unittest to get test results from subprocesses.
 
3
#  Copyright (C) 2005  Robert Collins <robertc@robertcollins.net>
 
4
#
 
5
#  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
 
6
#  license at the users choice. A copy of both licenses are available in the
 
7
#  project source as Apache-2.0 and BSD. You may not use this file except in
 
8
#  compliance with one of these two licences.
 
9
#  
 
10
#  Unless required by applicable law or agreed to in writing, software
 
11
#  distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
 
12
#  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 
13
#  license you chose for the specific language governing permissions and
 
14
#  limitations under that license.
 
15
#
 
16
 
 
17
"""Tests for subunit.TestResultStats."""
 
18
 
 
19
import unittest
 
20
from StringIO import StringIO
 
21
 
 
22
import subunit
 
23
 
 
24
 
 
25
class TestTestResultStats(unittest.TestCase):
 
26
    """Test for TestResultStats, a TestResult object that generates stats."""
 
27
 
 
28
    def setUp(self):
 
29
        self.output = StringIO()
 
30
        self.result = subunit.TestResultStats(self.output)
 
31
        self.input_stream = StringIO()
 
32
        self.test = subunit.ProtocolTestCase(self.input_stream)
 
33
 
 
34
    def test_stats_empty(self):
 
35
        self.test.run(self.result)
 
36
        self.assertEqual(0, self.result.total_tests)
 
37
        self.assertEqual(0, self.result.passed_tests)
 
38
        self.assertEqual(0, self.result.failed_tests)
 
39
        self.assertEqual(set(), self.result.seen_tags)
 
40
 
 
41
    def setUpUsedStream(self):
 
42
        self.input_stream.write("""tags: global
 
43
test passed
 
44
success passed
 
45
test failed
 
46
tags: local
 
47
failure failed
 
48
test error
 
49
error error
 
50
test skipped
 
51
skip skipped
 
52
test todo
 
53
xfail todo
 
54
""")
 
55
        self.input_stream.seek(0)
 
56
        self.test.run(self.result)
 
57
    
 
58
    def test_stats_smoke_everything(self):
 
59
        # Statistics are calculated usefully.
 
60
        self.setUpUsedStream()
 
61
        self.assertEqual(5, self.result.total_tests)
 
62
        self.assertEqual(2, self.result.passed_tests)
 
63
        self.assertEqual(2, self.result.failed_tests)
 
64
        self.assertEqual(1, self.result.skipped_tests)
 
65
        self.assertEqual(set(["global", "local"]), self.result.seen_tags)
 
66
 
 
67
    def test_stat_formatting(self):
 
68
        expected = ("""
 
69
Total tests:       5
 
70
Passed tests:      2
 
71
Failed tests:      2
 
72
Skipped tests:     1
 
73
Seen tags: global, local
 
74
""")[1:]
 
75
        self.setUpUsedStream()
 
76
        self.result.formatStats()
 
77
        self.assertEqual(expected, self.output.getvalue())
 
78
 
 
79
 
 
80
def test_suite():
 
81
    loader = subunit.tests.TestUtil.TestLoader()
 
82
    result = loader.loadTestsFromName(__name__)
 
83
    return result