1- # Copyright (c) 2018, 2023 , Oracle and/or its affiliates.
1+ # Copyright (c) 2018, 2026 , Oracle and/or its affiliates.
22# Copyright (C) 1996-2020 Python Software Foundation
33#
44# Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5-
5+ import os
6+ import subprocess
7+ import sys
8+ import tempfile
69import unittest
710
811class MyIndexable (object ):
@@ -68,7 +71,7 @@ def test_chr(self):
6871 self .assertEqual (chr (97 ), 'a' )
6972 self .assertEqual (chr (0xfff ), '\u0fff ' )
7073 self .assertEqual (chr (0xf0000 ), '\U000f0000 ' )
71-
74+
7275 def test_ord (self ):
7376 self .assertEqual (ord (' ' ), 32 )
7477 self .assertEqual (ord ('a' ), 97 )
@@ -93,19 +96,26 @@ def test_min(self):
9396
9497 def test_sort_keyfunc (self ):
9598 lists = [[], [1 ], [1 ,2 ], [1 ,2 ,3 ], [1 ,3 ,2 ], [3 ,2 ,1 ], [9 ,3 ,8 ,1 ,7 ,9 ,3 ,6 ,7 ,8 ]]
96-
99+
97100 for l in lists :
98101 count = 0
99-
102+
100103 def keyfunc (v ):
101104 nonlocal count
102105 count += 1
103106 return v
104-
107+
105108 result = sorted (l , key = keyfunc )
106109 self .assertEqual (len (l ), count )
107110 self .assertEqual (sorted (l ), result )
108111 count = 0
109112 result = sorted (l , key = keyfunc , reverse = True )
110113 self .assertEqual (len (l ), count )
111- self .assertEqual (sorted (l , reverse = True ), result )
114+ self .assertEqual (sorted (l , reverse = True ), result )
115+
116+ def test_license (self ):
117+ with tempfile .TemporaryDirectory () as tmpdir :
118+ # Test that it can find the license even when ran outside of the distribution
119+ license = subprocess .check_output ([sys .executable , "-c" , "print(license())" ], cwd = tmpdir , text = True , input = ("\n " * 100 ))
120+ if sys .implementation .name == 'graalpy' :
121+ self .assertIn ('Oracle' , license )
0 commit comments