Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump chai and @types/chai #252

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions test/arrays.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pymport, proxify, PyObject, pyval } from 'pymport';
import { getPythonType, toPythonArray, toTypedArray } from 'pymport/array';
import { getPythonType, toPythonArray, toTypedArray, TypedArray } from 'pymport/array';
import { assert } from 'chai';

const tests = [
Expand All @@ -13,7 +13,7 @@ const tests = [
BigInt64Array,
Float32Array,
Float64Array
];
] as const;

describe('array', () => {
const array = proxify(pymport('array'));
Expand All @@ -23,10 +23,10 @@ describe('array', () => {

assert.instanceOf(a, PyObject);
assert.equal(a.type, 'array.array');
assert.equal(a.typecode, 'l');
assert.equal((a as any).typecode, 'l');
assert.lengthOf(a, 10);

assert.equal(a.item(4), 4); // Implicit conversion using Symbol.toPrimitive
assert.equal(a.item(4), 4 as any); // Implicit conversion using Symbol.toPrimitive
assert.strictEqual(a.item(4).toJS(), 4);
});

Expand All @@ -35,8 +35,8 @@ describe('array', () => {
it('export to TypedArray', () => {
const a = array.array(getPythonType(new cons(1)), pyval('range(10)'));

const t = toTypedArray(a) as any;
assert.instanceOf(t, cons);
const t = toTypedArray(a) as TypedArray;
assert.instanceOf(t, cons as typeof tests[0]);
assert.lengthOf(t, 10);
assert.equal(t[4], 4);
});
Expand All @@ -50,10 +50,10 @@ describe('array', () => {

assert.instanceOf(a, PyObject);
assert.equal(a.type, 'array.array');
assert.equal(a.typecode, getPythonType(t));
assert.equal((a as any).typecode, getPythonType(t));
assert.lengthOf(a, 10);

assert.equal(a.item(4), 4); // Implicit conversion using Symbol.toPrimitive
assert.equal(a.item(4), 4 as any); // Implicit conversion using Symbol.toPrimitive
assert.strictEqual(a.item(4).toJS(), 4);
});
});
Expand Down
10 changes: 5 additions & 5 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('proxy', () => {
const py = PyObject.fromJS({ name: 'value' });

assert.instanceOf(py, PyObject);
assert.instanceOf(py.__PyObject__, PyObject);
assert.instanceOf((py as any).__PyObject__, PyObject);
});

it('proxified objects return unique references', () => {
Expand Down Expand Up @@ -121,13 +121,13 @@ describe('proxy', () => {
it('passing proxified arguments', () => {
const py_array = pyval('np.array([2, 1, 0]).tolist()', { np });
assert.instanceOf(py_array, PyObject);
assert.deepEqual(py_array.toJS(), [2, 1, 0]);
assert.deepEqual((py_array as any).toJS(), [2, 1, 0]);
});

it('automatic conversion to JS objects through Symbol.toPrimitive', () => {
const num = PyObject.int(10);
assert.instanceOf(num, PyObject);
assert.equal(+num, 10);
assert.equal(+(num as any), 10);
assert.throws(() => assert.strictEqual(num, 10));
});

Expand Down Expand Up @@ -240,8 +240,8 @@ describe('proxy', () => {

const staticMember = klass.static_member;
assert.instanceOf(staticMember, PyObject);
assert.strictEqual(staticMember.type, 'int');
assert.strictEqual(staticMember.toJS(), 42);
assert.strictEqual((staticMember as any).type, 'int');
assert.strictEqual((staticMember as any).toJS(), 42);

const name = klass.name;
assert.instanceOf(name.__PyObject__, PyObject);
Expand Down
4 changes: 2 additions & 2 deletions test/pymport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { pymport, PyObject, PythonError, version } from 'pymport';
import chai from 'chai';
import spies from 'chai-spies';
chai.use(spies);
const assert = chai.assert;
const expect = chai.expect;
const assert: Chai.AssertStatic = chai.assert;
const expect: Chai.ExpectStatic = chai.expect;

describe('pymport', () => {
it('version', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ describe('types', () => {
it('constructor', () => {
const fn = PyObject.func((a: any) => {
assert.instanceOf(a, PyObject);
return a + 2;
return (a as any) + 2;
});

assert.instanceOf(fn, PyObject);
Expand Down
Loading