pybricksMicropython: implement appending imports

This implements appending compiled imported modules for the multi-mpy6
file format.
This commit is contained in:
David Lechner
2022-10-19 18:26:37 -05:00
committed by David Lechner
parent 8b19ad5866
commit be9272ca9c
6 changed files with 410 additions and 22 deletions
+44
View File
@@ -3,6 +3,7 @@
import {
FileNameValidationResult,
findImportedModules,
pythonFileExtension,
pythonFileExtensionRegex,
validateFileName,
@@ -76,3 +77,46 @@ describe('validateFileName', () => {
);
});
});
test('findImportedModules', async () => {
const script = `
import a
import b, c
import d.d
import e.e as e
import f.f as f, g
from h import x
from h import x as y
from i import (x, y)
from i import (x as y, z)
from j import *
from . import x
from . import x as y
from .r import x
from ..r import x
from ...r import x
from ....r import x
`;
const modules = findImportedModules(script);
expect(modules).toEqual(
new Set([
'a',
'b',
'c',
'd.d',
'e.e',
'f.f',
'g',
'h',
'i',
'j',
'.',
'.r',
'..r',
'...r',
'....r',
]),
);
});