Description: Tests to Python3
Author: Antoni Villalonga i Noceras <antoni@friki.cat>, Nilesh Patra <nilesh@debian.org>
Last-Update: Sun, Jan 1, 2023
--- a/tests/test_merge.py
+++ b/tests/test_merge.py
@@ -4,6 +4,8 @@
 import subprocess
 import pytest
 
+from common_py import getpyvers
+currpy = getpyvers()
 
 import tempfile
 
@@ -22,7 +24,7 @@
     try:
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "sort",
@@ -34,7 +36,7 @@
 
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "sort",
@@ -54,7 +56,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "merge",
@@ -102,7 +104,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "merge",
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -6,6 +6,9 @@
 
 import subprocess
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -20,7 +23,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "parse",
@@ -64,7 +67,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "parse",
--- a/tests/test_select.py
+++ b/tests/test_select.py
@@ -5,6 +5,9 @@
 import pytest
 from pairtools.lib import pairsam_format
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 mock_pairsam_path = os.path.join(testdir, "data", "mock.pairsam")
 mock_chromsizes_path = os.path.join(testdir, "data", "mock.chrom.sizes")
@@ -13,7 +16,7 @@
 def test_preserve():
     try:
         result = subprocess.check_output(
-            ["python", "-m", "pairtools", "select", "True", mock_pairsam_path],
+            [currpy, "-m", "pairtools", "select", "True", mock_pairsam_path],
         ).decode("ascii")
     except subprocess.CalledProcessError as e:
         print(e.output)
@@ -35,7 +38,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
@@ -68,7 +71,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
@@ -101,7 +104,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
@@ -136,7 +139,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
@@ -169,7 +172,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
@@ -221,7 +224,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "select",
--- a/tests/test_sort.py
+++ b/tests/test_sort.py
@@ -4,6 +4,9 @@
 import subprocess
 import pytest
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -11,7 +14,7 @@
     mock_pairsam_path = os.path.join(testdir, "data", "mock.pairsam")
     try:
         result = subprocess.check_output(
-            ["python", "-m", "pairtools", "sort", mock_pairsam_path],
+            [currpy, "-m", "pairtools", "sort", mock_pairsam_path],
         ).decode("ascii")
     except subprocess.CalledProcessError as e:
         print(e.output)
--- a/tests/test_split.py
+++ b/tests/test_split.py
@@ -5,6 +5,9 @@
 import pytest
 import tempfile
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 mock_pairsam_path = os.path.join(testdir, "data", "mock.pairsam")
 
@@ -19,7 +22,7 @@
     try:
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "split",
--- a/tests/test_stats.py
+++ b/tests/test_stats.py
@@ -5,6 +5,9 @@
 import numpy as np
 import yaml
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -12,7 +15,7 @@
     mock_pairsam_path = os.path.join(testdir, "data", "mock.4stats.pairs")
     try:
         result = subprocess.check_output(
-            ["python", "-m", "pairtools", "stats", "--yaml", mock_pairsam_path],
+            [currpy, "-m", "pairtools", "stats", "--yaml", mock_pairsam_path],
         ).decode("ascii")
     except subprocess.CalledProcessError as e:
         print(e.output)
@@ -65,7 +68,7 @@
     try:
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "stats",
@@ -78,7 +81,7 @@
 
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "stats",
@@ -90,7 +93,7 @@
         )
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "stats",
@@ -103,7 +106,7 @@
         )
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "stats",
@@ -116,7 +119,7 @@
         )
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "stats",
--- a/tests/test_flip.py
+++ b/tests/test_flip.py
@@ -4,6 +4,9 @@
 import subprocess
 import pytest
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 mock_pairs_path = os.path.join(testdir, "data", "mock.4flip.pairs")
 mock_chromsizes_path = os.path.join(testdir, "data", "mock.chrom.sizes")
@@ -13,7 +16,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "flip",
--- a/tests/test_markasdup.py
+++ b/tests/test_markasdup.py
@@ -4,6 +4,9 @@
 import subprocess
 import pytest
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -11,7 +14,7 @@
     mock_pairsam_path = os.path.join(testdir, "data", "mock.pairsam")
     try:
         result = subprocess.check_output(
-            ["python", "-m", "pairtools", "markasdup", mock_pairsam_path],
+            [currpy, "-m", "pairtools", "markasdup", mock_pairsam_path],
         ).decode("ascii")
     except subprocess.CalledProcessError as e:
         print(e.output)
--- a/tests/test_dedup.py
+++ b/tests/test_dedup.py
@@ -5,6 +5,9 @@
 import pytest
 import tempfile
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 tmpdir = tempfile.TemporaryDirectory()
@@ -32,7 +35,7 @@
     try:
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "dedup",
@@ -49,7 +52,7 @@
         )
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "dedup",
@@ -68,7 +71,7 @@
         )
         subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "dedup",
--- a/tests/test_filterbycov.py
+++ b/tests/test_filterbycov.py
@@ -5,6 +5,9 @@
 import pytest
 import tempfile
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 mock_pairs_path_filterbycov = os.path.join(testdir, "data", "mock.4filterbycov.pairs")
@@ -37,7 +40,7 @@
         for p in params:
             subprocess.check_output(
                 [
-                    "python",
+                    currpy,
                     "-m",
                     "pairtools",
                     "filterbycov",
--- a/tests/test_header.py
+++ b/tests/test_header.py
@@ -5,6 +5,9 @@
 
 import subprocess
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -22,7 +25,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "header",
--- a/tests/test_parse2.py
+++ b/tests/test_parse2.py
@@ -6,6 +6,9 @@
 
 import subprocess
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -15,7 +18,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "parse2",
@@ -75,7 +78,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "parse2",
--- a/tests/test_restrict.py
+++ b/tests/test_restrict.py
@@ -6,6 +6,9 @@
 
 import subprocess
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -16,7 +19,7 @@
     try:
         result = subprocess.check_output(
             [
-                "python",
+                currpy,
                 "-m",
                 "pairtools",
                 "restrict",
--- a/tests/test_scaling.py
+++ b/tests/test_scaling.py
@@ -6,6 +6,9 @@
 import pandas as pd
 import io
 
+from common_py import getpyvers
+currpy = getpyvers()
+
 testdir = os.path.dirname(os.path.realpath(__file__))
 
 
@@ -13,7 +16,7 @@
     mock_pairsam_path = os.path.join(testdir, "data", "mock.pairsam")
     try:
         result = subprocess.check_output(
-            ["python", "-m", "pairtools", "scaling", mock_pairsam_path],
+            [currpy, "-m", "pairtools", "scaling", mock_pairsam_path],
         ).decode("ascii")
     except subprocess.CalledProcessError as e:
         print(e.output)
--- /dev/null
+++ b/tests/common_py.py
@@ -0,0 +1,6 @@
+import os
+
+def getpyvers():
+    if 'CURPY' in os.environ:
+        return os.getenv('CURPY')
+    return 'python3'
