Skip to content

Commit

Permalink
Bug 1526580 [wpt PR 15248] - Update apiclient, a=testonly
Browse files Browse the repository at this point in the history
Automatic update from web-platform-tests
Squashed 'css/tools/apiclient/' changes from 9d80ee4507..f0e1aa75a7

f0e1aa75a7 Merge pull request #2 from cclauss/modernize-Python-2-codes
08bedeaf9d Use print() function in both Python 2 and Python 3

git-subtree-dir: css/tools/apiclient
git-subtree-split: f0e1aa75a7113c2df87ab76cdf6734e77dfbaeb7

--
Merge commit '77ff57a73af15f3ac3743a3eedf59d4acf6d0a41' into update-apiclient

--
Merge pull request #15248 from gsnedders/update-apiclient

Update apiclient
--

wpt-commits: 77ff57a73af15f3ac3743a3eedf59d4acf6d0a41, 83364c672a2c3857fd8fa522327c103f1490155b, edc48a7c1238f7cf8216746cd287a51cce6f0ced
wpt-pr: 15248
  • Loading branch information
gsnedders authored and moz-wptsync-bot committed Feb 21, 2019
1 parent aefb4c2 commit 90af8e7
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions testing/web-platform/tests/css/tools/apiclient/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
#

from __future__ import print_function
import sys
import os
import glob
Expand All @@ -24,11 +25,11 @@

def runTests(testFileSearch):
for testFilePath in glob.glob(testFileSearch):
print 'Running tests from: ' + testFilePath
print('Running tests from: ' + testFilePath)
with open(testFilePath) as testFile:
testData = json.load(testFile, object_pairs_hook = collections.OrderedDict)
for testSetName in testData:
print testSetName + ':'
print(testSetName + ':')
testSet = testData[testSetName]
vars = testSet['variables']
for test in testSet['testcases']:
Expand All @@ -37,31 +38,31 @@ def runTests(testFileSearch):
template = uritemplate.URITemplate(test[0])
except Exception as e:
if (expectedResult):
print '* FAIL: "' + test[0] + '" got: None, expected "' + expectedResult + '"'
print('* FAIL: "' + test[0] + '" got: None, expected "' + expectedResult + '"')
else:
print ' PASS: "' + test[0] + '" == None'
print(' PASS: "' + test[0] + '" == None')
continue

result = template.expand(**vars)
if (isinstance(expectedResult, basestring)):
if (expectedResult != result):
print '* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected "' + expectedResult + '"'
print('* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected "' + expectedResult + '"')
continue
elif (isinstance(expectedResult, list)):
for possibleResult in expectedResult:
if (possibleResult == result):
break
else:
print '* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected:'
print " or\n".join([' "' + possibleResult + '"' for possibleResult in expectedResult])
print('* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected:')
print(" or\n".join([' "' + possibleResult + '"' for possibleResult in expectedResult]))
continue
elif (not expectedResult):
if (result):
print '* FAIL "' + test[0] + '" got: "' + unicode(result) + '", expected None'
print('* FAIL "' + test[0] + '" got: "' + unicode(result) + '", expected None')
continue
else:
print '** Unknown expected result type: ' + repr(expectedResult)
print ' PASS: "' + test[0] + '" == "' + result + '"'
print('** Unknown expected result type: ' + repr(expectedResult))
print(' PASS: "' + test[0] + '" == "' + result + '"')

def debugHook(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
Expand All @@ -72,7 +73,7 @@ def debugHook(type, value, tb):
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
print()
# ...then start the debugger in post-mortem mode.
pdb.pm()

Expand All @@ -88,18 +89,18 @@ def debugHook(type, value, tb):


github = apiclient.APIClient('https://api.github.com/', version = 'vnd.github.beta')
print github.get('user_url', user = 'plinss').data
print(github.get('user_url', user = 'plinss').data)

# shepherd = apiclient.APIClient('https://api.csswg.org/shepherd/', version = 'vnd.csswg.shepherd.v1')
shepherd = apiclient.APIClient('https://test.linss.com/shepherd/api', version = 'vnd.csswg.shepherd.v1')
print shepherd.resourceNames
print(shepherd.resourceNames)
specs = shepherd.resource('specifications')
print specs.variables
print(specs.variables)
# print specs.hints.docs
print shepherd.get('specifications', spec = 'compositing-1', anchors = False).data
print(shepherd.get('specifications', spec = 'compositing-1', anchors = False).data)

suites = shepherd.resource('test_suites')
print suites.variables
print shepherd.get('test_suites', spec = 'css-shapes-1').data
print(suites.variables)
print(shepherd.get('test_suites', spec = 'css-shapes-1').data)


0 comments on commit 90af8e7

Please sign in to comment.