bpo-35683: Improve Azure Pipelines steps (GH-11493)


diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 8d44caf..32ac440 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -1,5 +1,6 @@
 import datetime
 import faulthandler
+import json
 import locale
 import os
 import platform
@@ -565,6 +566,9 @@
 
         if self.ns.tempdir:
             TEMPDIR = self.ns.tempdir
+        elif self.ns.worker_args:
+            ns_dict, _ = json.loads(self.ns.worker_args)
+            TEMPDIR = ns_dict.get("tempdir") or TEMPDIR
 
         os.makedirs(TEMPDIR, exist_ok=True)
 
diff --git a/Lib/test/test_symbol.py b/Lib/test/test_symbol.py
index ed86aec..645d8f4 100644
--- a/Lib/test/test_symbol.py
+++ b/Lib/test/test_symbol.py
@@ -2,6 +2,7 @@
 from test import support
 import os
 import sys
+import sysconfig
 import subprocess
 
 
@@ -38,8 +39,8 @@
             lines2 = fp.readlines()
         self.assertEqual(lines1, lines2)
 
-    @unittest.skipIf(not os.path.exists(GRAMMAR_FILE),
-                     'test only works from source build directory')
+    @unittest.skipUnless(sysconfig.is_python_build(),
+                         'test only works from source build directory')
     def test_real_grammar_and_symbol_file(self):
         output = support.TESTFN
         self.addCleanup(support.unlink, output)