Skip to content

Commit

Permalink
Fix #208: Handle deprecation removals in Python 3.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Oct 23, 2023
1 parent 65a014b commit e27569b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 12 additions & 4 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2022 Vinay Sajip.
# Copyright (C) 2012-2023 Vinay Sajip.
# Licensed to the Python Software Foundation under a contributor agreement.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
Expand Down Expand Up @@ -327,13 +327,21 @@ def test_dry_run(self):
self.assertFalse(ofiles)

def test_script_run(self):
files = self.maker.make('test = cgi:print_directory')
if sys.version_info[:2] < (3, 13):
target = 'cgi:print_directory'
else:
target = 'test.support.interpreters:list_all'
files = self.maker.make('test = %s' % target)
self.assertEqual(len(files), 2)
p = subprocess.Popen([sys.executable, files[0]],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
self.assertIn(os.getcwd().encode('utf-8'), stdout)
if sys.version_info[:2] < (3, 13):
self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
self.assertIn(os.getcwd().encode('utf-8'), stdout)
else:
self.assertIn(b'[Interpreter(id=0, isolated=None)]', stderr)
self.assertEqual(p.returncode, 1)

@unittest.skipUnless(os.name == 'posix', 'Test only valid for POSIX')
def test_mode(self):
Expand Down
17 changes: 12 additions & 5 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#
# Copyright (C) 2012-2013 The Python Software Foundation.
# Copyright (C) 2012-2023 The Python Software Foundation.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
"""Tests for distlib.version."""
import doctest
import sys

from compat import unittest
from support import DistlibTestCase
Expand Down Expand Up @@ -645,10 +646,16 @@ def is_less(v1, v2):
def test_suite():
#README = os.path.join(os.path.dirname(__file__), 'README.txt')
#suite = [doctest.DocFileSuite(README), unittest.makeSuite(VersionTestCase)]
suite = [unittest.makeSuite(VersionTestCase),
unittest.makeSuite(CompatibilityTestCase),
unittest.makeSuite(LegacyVersionTestCase),
unittest.makeSuite(SemanticVersionTestCase)]
if sys.version_info[:2] < (3, 13):
suite = [unittest.makeSuite(VersionTestCase),
unittest.makeSuite(CompatibilityTestCase),
unittest.makeSuite(LegacyVersionTestCase),
unittest.makeSuite(SemanticVersionTestCase)]
else:
suite = unittest.defaultTestLoader.loadTestsFromNames([
'VersionTestCase', 'CompatibilityTestCase',
'LegacyVersionTestCase', 'SemanticVersionTestCase'
], module=sys.modules['__main__'])
return unittest.TestSuite(suite)

if __name__ == "__main__": # pragma: no cover
Expand Down

0 comments on commit e27569b

Please sign in to comment.