Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Commit 7cdbc2a

Browse files
authored
Merge branch 'master' into patch-5
2 parents 50df11d + e531f3a commit 7cdbc2a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/PythonKitTests/PythonRuntimeTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,22 @@ class PythonRuntimeTests: XCTestCase {
326326
}
327327
XCTAssertEqual(bytes, otherBytes)
328328
}
329+
330+
func testPythonFunction() {
331+
let versionMajor = Python.versionInfo.major
332+
let versionMinor = Python.versionInfo.minor
333+
guard (versionMajor == 3 && versionMinor >= 1) || versionMajor > 3 else {
334+
return
335+
}
336+
337+
let pythonAdd = PythonFunction { (params: [PythonObject]) in
338+
let lhs = params[0]
339+
let rhs = params[1]
340+
return lhs + rhs
341+
}.pythonObject
342+
343+
let pythonSum = pythonAdd(2, 3)
344+
XCTAssertNotNil(Double(pythonSum))
345+
XCTAssertEqual(pythonSum, 5)
346+
}
329347
}

0 commit comments

Comments
 (0)