Skip to content

Commit f74ce9e

Browse files
committed
Files that were not included in r7115
1 parent 94fee9f commit f74ce9e

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.python.tests.constructor_kwargs;
2+
3+
import junit.framework.TestCase;
4+
5+
import org.python.core.PyString;
6+
import org.python.core.PyStringMap;
7+
import org.python.core.PySystemState;
8+
import org.python.util.PythonInterpreter;
9+
10+
public class ConstructorKWArgsTest extends TestCase {
11+
12+
private PythonInterpreter interp;
13+
14+
@Override
15+
protected void setUp() throws Exception {
16+
PySystemState sys = new PySystemState();
17+
interp = new PythonInterpreter(new PyStringMap(), sys);
18+
}
19+
20+
public void testConstructorKWArgs() {
21+
interp.execfile("tests/python/constructorkwargs_test.py");
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.python.tests.constructor_kwargs;
2+
3+
import java.util.HashMap;
4+
import java.util.Arrays;
5+
6+
import org.python.core.PyObject;
7+
8+
public class KWArgsObject {
9+
private HashMap<String, PyObject> data = new HashMap<String, PyObject>();
10+
11+
public KWArgsObject(PyObject[] values, String[] names) {
12+
int offset = values.length-names.length;
13+
for (int i = 0; i<names.length; i++) {
14+
data.put(names[i], values[offset+i]);
15+
}
16+
}
17+
18+
public PyObject getValue(String key) {
19+
return data.get(key);
20+
}
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from org.python.tests.constructor_kwargs import KWArgsObject
2+
3+
x = KWArgsObject(a=1, b=2, c=3)
4+
5+
assert x.getValue('a') == 1
6+
assert x.getValue('b') == 2
7+
assert x.getValue('c') == 3
8+

0 commit comments

Comments
 (0)