[med-svn] [python-dendropy] 01/03: Upstream patch to skip tests that are requiring installation of non-free software (PAUP)

Andreas Tille tille at debian.org
Wed Jun 24 12:09:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository python-dendropy.

commit 1f7eeae1599537aafea15c89642e5cb80d7dc997
Author: Andreas Tille <tille at debian.org>
Date:   Wed Jun 24 14:05:08 2015 +0200

    Upstream patch to skip tests that are requiring installation of non-free software (PAUP)
---
 ...PAUP-based-tests-unless-path-to-PAUP-is-p.patch | 281 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 282 insertions(+)

diff --git a/debian/patches/0002-Do-not-run-PAUP-based-tests-unless-path-to-PAUP-is-p.patch b/debian/patches/0002-Do-not-run-PAUP-based-tests-unless-path-to-PAUP-is-p.patch
new file mode 100644
index 0000000..ab1f878
--- /dev/null
+++ b/debian/patches/0002-Do-not-run-PAUP-based-tests-unless-path-to-PAUP-is-p.patch
@@ -0,0 +1,281 @@
+From b6b932e5c0bd65384015c759ebf281e561e4da07 Mon Sep 17 00:00:00 2001
+From: Jeet Sukumaran <jeetsukumaran at gmail.com>
+Date: Tue, 23 Jun 2015 10:04:34 -0400
+Subject: [PATCH] Do not run PAUP-based tests unless path to PAUP is provided
+
+---
+ README.rst                                     |  15 ++
+ dendropy/interop/paup.py                       |   2 +-
+ dendropy/test/test_datamodel_split_bitmasks.py | 221 +++++++++++++------------
+ 3 files changed, 129 insertions(+), 109 deletions(-)
+
+--- a/README.rst
++++ b/README.rst
+@@ -52,6 +52,21 @@ and more.
+ Testing
+ =======
+ 
++.. note::
++
++    Note that some tests rely on PAUP* being available on your system.
++    You will need to set the environmental variable ``DENDROPY_PAUP_EXECUTABLE_PATH`` to the path
++    of the PAUP* executable for these tests to be run, e.g.::
++
++        DENDROPY_PAUP_EXECUTABLE_PATH=/usr/local/bin/paup python setup.py test
++
++    or::
++
++        DENDROPY_PAUP_EXECUTABLE_PATH=/usr/local/bin/paup python -m unittest
++
++    If this variable is not set or set to "NONE", then any tests that rely on
++    PAUP* will NOT be run.
++
+ Tests can be run by typing::
+ 
+     $ python -m dendropy.test
+--- a/dendropy/interop/paup.py
++++ b/dendropy/interop/paup.py
+@@ -43,7 +43,7 @@ _LOG = messaging.get_logger(__name__)
+ 
+ import dendropy
+ 
+-PAUP_PATH = os.environ.get(metavar.DENDROPY_PAUP_PATH_ENVAR, "paup")
++PAUP_PATH = os.environ.get(metavar.DENDROPY_PAUP_PATH_ENVAR, "NONE")
+ if PAUP_PATH == "NONE":
+     DENDROPY_PAUP_INTEROPERABILITY = False
+ else:
+--- a/dendropy/test/test_datamodel_split_bitmasks.py
++++ b/dendropy/test/test_datamodel_split_bitmasks.py
+@@ -141,111 +141,115 @@ class SplitDistributionTestCases(Extende
+                         use_tree_weights=use_weights,
+                         expected_num_trees=num_trees)
+ 
+-class SplitCountTest(ExtendedTestCase):
+-
+-    @classmethod
+-    def setUpClass(cls):
+-        if sys.version_info.major < 3:
+-            cls.assertRaisesRegex = cls.assertRaisesRegexp
+-
+-    def check_split_counting(self,
+-            tree_filename,
+-            test_as_rooted,
+-            parser_rooting_interpretation,
+-            test_ignore_tree_weights=False,
+-            dp_ignore_tree_weights=False,
+-            ):
+-        tree_filepath = pathmap.tree_source_path(tree_filename)
+-        ps = paup.PaupService()
+-        paup_sd = ps.get_split_distribution_from_files(
+-                tree_filepaths=[tree_filepath],
+-                is_rooted=test_as_rooted,
+-                use_tree_weights=not test_ignore_tree_weights,
+-                burnin=0,
+-                taxa_definition_filepath=tree_filepath
++if not paup.DENDROPY_PAUP_INTEROPERABILITY:
++    _LOG.warn("PAUP interoperability not available: skipping split counting tests")
++else:
++
++    class SplitCountTest(ExtendedTestCase):
++
++        @classmethod
++        def setUpClass(cls):
++            if sys.version_info.major < 3:
++                cls.assertRaisesRegex = cls.assertRaisesRegexp
++
++        def check_split_counting(self,
++                tree_filename,
++                test_as_rooted,
++                parser_rooting_interpretation,
++                test_ignore_tree_weights=False,
++                dp_ignore_tree_weights=False,
++                ):
++            tree_filepath = pathmap.tree_source_path(tree_filename)
++            ps = paup.PaupService()
++            paup_sd = ps.get_split_distribution_from_files(
++                    tree_filepaths=[tree_filepath],
++                    is_rooted=test_as_rooted,
++                    use_tree_weights=not test_ignore_tree_weights,
++                    burnin=0,
++                    taxa_definition_filepath=tree_filepath
++                    )
++            taxon_namespace = paup_sd.taxon_namespace
++            dp_sd = dendropy.SplitDistribution(taxon_namespace=taxon_namespace)
++            dp_sd.ignore_edge_lengths = True
++            dp_sd.ignore_node_ages = True
++            dp_sd.ignore_tree_weights = dp_ignore_tree_weights
++            taxa_mask = taxon_namespace.all_taxa_bitmask()
++            taxon_namespace.is_mutable = False
++            trees = dendropy.TreeList.get_from_path(tree_filepath,
++                    "nexus",
++                    rooting=parser_rooting_interpretation,
++                    taxon_namespace=taxon_namespace)
++            for tree in trees:
++                self.assertIs(tree.taxon_namespace, taxon_namespace)
++                self.assertIs(tree.taxon_namespace, dp_sd.taxon_namespace)
++                dp_sd.count_splits_on_tree(
++                        tree,
++                        is_bipartitions_updated=False)
++            self.assertEqual(dp_sd.total_trees_counted, paup_sd.total_trees_counted)
++            taxa_mask = taxon_namespace.all_taxa_bitmask()
++            for split in dp_sd.split_counts:
++                if not dendropy.Bipartition.is_trivial_bitmask(split, taxa_mask):
++                    # if split not in paup_sd.split_counts:
++                    #     print("{}: {}".format(split, split in paup_sd.split_counts))
++                    #     s2 = taxon_namespace.normalize_bitmask(split)
++                    #     print("{}: {}".format(s2, s2 in paup_sd.split_counts))
++                    #     s3 = ~split & taxon_namespace.all_taxa_bitmask()
++                    #     print("{}: {}".format(s3, s3 in paup_sd.split_counts))
++                    self.assertIn(split, paup_sd.split_counts, "split not found")
++                    self.assertEqual(dp_sd.split_counts[split], paup_sd.split_counts[split], "incorrect split frequency")
++                    del paup_sd.split_counts[split]
++            remaining_splits = list(paup_sd.split_counts.keys())
++            for split in remaining_splits:
++                if dendropy.Bipartition.is_trivial_bitmask(split, taxa_mask):
++                    del paup_sd.split_counts[split]
++            self.assertEqual(len(paup_sd.split_counts), 0)
++
++        def test_basic_split_count_with_incorrect_rootings_raises_error(self):
++            assertion_error_regexp1 = re.compile("(incorrect split frequency|split not found)")
++            test_cases = (
++                ('pythonidae.reference-trees.nexus', True, "force-unrooted", assertion_error_regexp1),
++                ('feb032009.trees.nexus', False, "force-rooted", assertion_error_regexp1),
+                 )
+-        taxon_namespace = paup_sd.taxon_namespace
+-        dp_sd = dendropy.SplitDistribution(taxon_namespace=taxon_namespace)
+-        dp_sd.ignore_edge_lengths = True
+-        dp_sd.ignore_node_ages = True
+-        dp_sd.ignore_tree_weights = dp_ignore_tree_weights
+-        taxa_mask = taxon_namespace.all_taxa_bitmask()
+-        taxon_namespace.is_mutable = False
+-        trees = dendropy.TreeList.get_from_path(tree_filepath,
+-                "nexus",
+-                rooting=parser_rooting_interpretation,
+-                taxon_namespace=taxon_namespace)
+-        for tree in trees:
+-            self.assertIs(tree.taxon_namespace, taxon_namespace)
+-            self.assertIs(tree.taxon_namespace, dp_sd.taxon_namespace)
+-            dp_sd.count_splits_on_tree(
+-                    tree,
+-                    is_bipartitions_updated=False)
+-        self.assertEqual(dp_sd.total_trees_counted, paup_sd.total_trees_counted)
+-        taxa_mask = taxon_namespace.all_taxa_bitmask()
+-        for split in dp_sd.split_counts:
+-            if not dendropy.Bipartition.is_trivial_bitmask(split, taxa_mask):
+-                # if split not in paup_sd.split_counts:
+-                #     print("{}: {}".format(split, split in paup_sd.split_counts))
+-                #     s2 = taxon_namespace.normalize_bitmask(split)
+-                #     print("{}: {}".format(s2, s2 in paup_sd.split_counts))
+-                #     s3 = ~split & taxon_namespace.all_taxa_bitmask()
+-                #     print("{}: {}".format(s3, s3 in paup_sd.split_counts))
+-                self.assertIn(split, paup_sd.split_counts, "split not found")
+-                self.assertEqual(dp_sd.split_counts[split], paup_sd.split_counts[split], "incorrect split frequency")
+-                del paup_sd.split_counts[split]
+-        remaining_splits = list(paup_sd.split_counts.keys())
+-        for split in remaining_splits:
+-            if dendropy.Bipartition.is_trivial_bitmask(split, taxa_mask):
+-                del paup_sd.split_counts[split]
+-        self.assertEqual(len(paup_sd.split_counts), 0)
+-
+-    def test_basic_split_count_with_incorrect_rootings_raises_error(self):
+-        assertion_error_regexp1 = re.compile("(incorrect split frequency|split not found)")
+-        test_cases = (
+-            ('pythonidae.reference-trees.nexus', True, "force-unrooted", assertion_error_regexp1),
+-            ('feb032009.trees.nexus', False, "force-rooted", assertion_error_regexp1),
+-            )
+-        for test_case, test_as_rooted, parser_rooting_interpretation, assertion_error_regexp in test_cases:
+-            with self.assertRaisesRegex(AssertionError, assertion_error_regexp):
+-                self.check_split_counting(
+-                        test_case,
+-                        test_as_rooted=test_as_rooted,
+-                        parser_rooting_interpretation=parser_rooting_interpretation)
+-
+-    def test_basic_split_count_with_incorrect_weight_treatment_raises_error(self):
+-        assertion_error_regexp1 = re.compile("incorrect split frequency")
+-        test_cases = (
+-                ("cetaceans.mb.no-clock.mcmc.weighted-01.trees", False),
+-                ("cetaceans.mb.strict-clock.mcmc.weighted-01.trees", True),
+-            )
+-        for test_case, test_as_rooted in test_cases:
+-            with self.assertRaisesRegex(AssertionError, assertion_error_regexp1):
+-                self.check_split_counting(
+-                        test_case,
+-                        test_as_rooted=test_as_rooted,
+-                        parser_rooting_interpretation="default-rooted",
+-                        test_ignore_tree_weights=False,
+-                        dp_ignore_tree_weights=False,
+-                        )
+-
+-    def test_basic_split_counting_under_different_rootings(self):
+-        test_cases = (
+-            'pythonidae.reference-trees.nexus',
+-            'feb032009.trees.nexus',
+-            'maj-rule-bug1.trees.nexus',
+-            'maj-rule-bug2.trees.nexus',
+-            )
+-        for is_rooted in (True, False):
+-            if is_rooted:
+-                rooting = "force-rooted"
+-            else:
+-                rooting = "force-unrooted"
+-            for test_case in test_cases:
+-                self.check_split_counting(
+-                        test_case,
+-                        test_as_rooted=is_rooted,
+-                        parser_rooting_interpretation=rooting)
++            for test_case, test_as_rooted, parser_rooting_interpretation, assertion_error_regexp in test_cases:
++                with self.assertRaisesRegex(AssertionError, assertion_error_regexp):
++                    self.check_split_counting(
++                            test_case,
++                            test_as_rooted=test_as_rooted,
++                            parser_rooting_interpretation=parser_rooting_interpretation)
++
++        def test_basic_split_count_with_incorrect_weight_treatment_raises_error(self):
++            assertion_error_regexp1 = re.compile("incorrect split frequency")
++            test_cases = (
++                    ("cetaceans.mb.no-clock.mcmc.weighted-01.trees", False),
++                    ("cetaceans.mb.strict-clock.mcmc.weighted-01.trees", True),
++                )
++            for test_case, test_as_rooted in test_cases:
++                with self.assertRaisesRegex(AssertionError, assertion_error_regexp1):
++                    self.check_split_counting(
++                            test_case,
++                            test_as_rooted=test_as_rooted,
++                            parser_rooting_interpretation="default-rooted",
++                            test_ignore_tree_weights=False,
++                            dp_ignore_tree_weights=False,
++                            )
++
++        def test_basic_split_counting_under_different_rootings(self):
++            test_cases = (
++                'pythonidae.reference-trees.nexus',
++                'feb032009.trees.nexus',
++                'maj-rule-bug1.trees.nexus',
++                'maj-rule-bug2.trees.nexus',
++                )
++            for is_rooted in (True, False):
++                if is_rooted:
++                    rooting = "force-rooted"
++                else:
++                    rooting = "force-unrooted"
++                for test_case in test_cases:
++                    self.check_split_counting(
++                            test_case,
++                            test_as_rooted=is_rooted,
++                            parser_rooting_interpretation=rooting)
+ 
+ class CladeMaskTest(unittest.TestCase):
+ 
+@@ -374,7 +378,8 @@ class TestTreeSplitSupportCredibilitySco
+                 30.89000000000001 + len(self.trees.taxon_namespace))
+ 
+ if __name__ == "__main__":
+-    if paup.DENDROPY_PAUP_INTEROPERABILITY:
+-        unittest.main()
+-    else:
+-        _LOG.warn("PAUP interoperability not available: skipping split counting tests")
++    unittest.main()
++    # if paup.DENDROPY_PAUP_INTEROPERABILITY:
++    #     unittest.main()
++    # else:
++    #     _LOG.warn("PAUP interoperability not available: skipping split counting tests")
diff --git a/debian/patches/series b/debian/patches/series
index e9b3c95..158d2dc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-Fix-bug-where-encoding-for-default-locale-is-None.patch
+0002-Do-not-run-PAUP-based-tests-unless-path-to-PAUP-is-p.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-dendropy.git



More information about the debian-med-commit mailing list