All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Vermeulen <sven.vermeulen@siphos.be>
To: selinux@tycho.nsa.gov
Subject: [PATCH 1/2] sepolgen: Fix test that compares matchlist length
Date: Fri, 19 Jul 2013 22:11:16 +0200	[thread overview]
Message-ID: <20130719201115.GA20879@siphos.be> (raw)


When running the tests, the following failure occurs:

======================================================================
FAIL: test_append (test_matching.TestMatchList)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/portage/portage/dev-python/sepolgen-1.1.9-r1/work/sepolgen-1.1.9-2.7/tests/test_matching.py", line 94, in test_append
    self.assertEqual(len(ml), 1)
AssertionError: 2 != 1

>From the test code, it looks like we use the matchlist length as a way to deduce
if an .append() did the right thing or not (i.e. add to bastards or children).
However, the length for the matchlist is defined as the sum of the lengths of
both:

    def __len__(self):
        # Only return the length of the matches so
        # that this can be used to test if there is
        # a match.
        return len(self.children) + len(self.bastards)

As a result, the len(ml) should always increase with an append, and then check
the length of one of the two sublists (children or bastards) to find out if this
occurred in the right sublist.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
---
 sepolgen/tests/test_matching.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sepolgen/tests/test_matching.py b/sepolgen/tests/test_matching.py
index 2282eca..161e001 100644
--- a/sepolgen/tests/test_matching.py
+++ b/sepolgen/tests/test_matching.py
@@ -56,7 +56,7 @@ class TestMatchList(unittest.TestCase):
         a = matching.Match()
         a.dist = 200
         ml.append(a)
-        self.assertEqual(len(ml), 1)
+        self.assertEqual(len(ml), 2)
         self.assertEqual(len(ml.bastards), 1)
 
         ml.allow_info_dir_change = False
@@ -64,7 +64,7 @@ class TestMatchList(unittest.TestCase):
         a.dist = 0
         a.info_dir_change = True
         ml.append(a)
-        self.assertEqual(len(ml), 1)
+        self.assertEqual(len(ml), 3)
         self.assertEqual(len(ml.bastards), 2)
 
     def test_sort(self):
-- 
1.8.1.5


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

                 reply	other threads:[~2013-07-19 20:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130719201115.GA20879@siphos.be \
    --to=sven.vermeulen@siphos.be \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.