Test method and device of interpreter and computer equipment
By determining the target test function and sending scripts to the remote interpreter in the software interpreter test, the problems of low testing efficiency and insufficient flexibility in the existing technology are solved, and automated testing is realized on unauthorized terminals are improved. Flexibility and accuracy.
Patent Information
- Application Number
- CN202411293146.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-12-13
AI Technical Summary
The existing software interpreter testing methods are inefficient, the test scripts are not flexible, the test results are not intuitive, and it is difficult to conduct automated testing on terminals without software authorization.
By determining the target test function in the local interpreter environment, loading and sending the target script to the remote interpreter, using the communication module to realize cross-interpreter communication and code execution, displaying the test results, and improving the flexibility and accuracy of the test environment.
It realizes automated script operation on terminals without software authorization, improves test flexibility and accuracy, reduces the impact of environmental factors on test results, and reduces the cost of resource allocation.
Smart Images

Figure CN119127709A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software automated testing, and in particular to a testing method, device and computer equipment for an interpreter. Background Art
[0002] In the field of simulation testing, many softwares have the need for script editing functions. Usually, a built-in interpreter is used to implement the script editor function of the software, and then some specific functions are implemented by encapsulating custom methods. For this type of software, to test whether the methods provided by its editor can be used normally, test engineers usually write program scripts in the software editor to verify these methods. However, this method usually has low testing efficiency, and the subsequent maintenance and update of test scripts are not flexible and fast enough, and the display of test results is not intuitive enough. Summary of the invention
[0003] Based on this, the purpose of this application is to provide an interpreter testing method, device and computer equipment that can improve testing flexibility and accuracy to solve the technical problems mentioned in the above background technology.
[0004] In a first aspect, the present application provides a test method for an interpreter, including: Determine the target test function in the local interpreter environment according to the requirements to be tested; Loading a target script corresponding to the target test function from a script module, and sending the target script to a remote interpreter through a communication module; Receive the test results obtained when the remote interpreter executes the target script, and display the test results according to the type of the target test function.
[0005] In one embodiment, a target test function in the local interpreter environment is determined according to the test requirements, including: determining a corresponding file name parameter according to the test requirements triggered by a user response; associating the test requirements with key methods in different programming libraries and frameworks for executing core functions; and making a function call according to the file name parameter to obtain a target test function.
[0006] In one embodiment, the target script is sent to a remote interpreter through a communication module, including: determining a function class corresponding to the target test function through a key method module; the function class inherits the window operation class in the common module; the function class is used to define a key method, and the key method includes a static method; and calling the communication module based on the static method to send the target script to the remote interpreter.
[0007] In one embodiment, the communication module is called based on the static method to achieve sending of the target script to the remote interpreter, including: calling the communication method in the communication module based on the static method, and establishing a gateway with the remote interpreter through the communication method; defining the communication action with the remote interpreter through the code method corresponding to the gateway instance to achieve sending of the target script.
[0008] In one embodiment, after loading the target script corresponding to the target test function from the script module, it also includes: loading the environment configuration information corresponding to the test requirement from the configuration module; the environment configuration information at least includes the configuration module project path, image base path, log path, test report path and tested software installation path; sending the target script and environment configuration information to the remote interpreter through the communication module, so that the remote interpreter loads the environment configuration information and executes the target script to obtain the test result.
[0009] In one embodiment, the remote interpreter loads the environment configuration information and executes the target script to obtain the test result, including: preliminarily verifying whether the output of the target script meets expectations through assertion statements; when all assertions in the target script pass, loading the environment configuration information through the target test framework and executing the target script to obtain the test result.
[0010] In one embodiment, the local interpreter and the remote interpreter are Python interpreters running on the same terminal or different terminals; the target test function is a pytest test function based on the Python test framework; the communication module is an execnet module that realizes communication and code execution between multiple interpreters, and the execnet module is a distributed computing library based on Python programs.
[0011] In a second aspect, the present application also provides a test device for an interpreter, including: A test function determination module, used to determine a target test function in the local interpreter environment according to a requirement to be tested; A target script sending module is used to load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module; The test result display module is used to receive the test result obtained when the remote interpreter executes the target script, and display the test result according to the type of the target test function.
[0012] In a third aspect, the present application further provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above interpreter testing method when executing the computer program.
[0013] In a fourth aspect, the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above interpreter testing method are implemented.
[0014] The test method, device, computer equipment and readable storage medium of the above-mentioned interpreter determine the target test function in the local interpreter environment according to the requirements to be tested, then load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module, so that when the test result obtained when the remote interpreter executes the target script is received, the test result can be displayed according to the type of the target test function. Therefore, by automatically loading the target script from the local interpreter environment to the remote interpreter and executing it, the flexibility of the test environment is greatly improved, and the problem of running the automated script directly through the cross-interpreter feature on some terminals without software authorization can be solved, so as to call the interpreter through the authorized terminal and realize the flexible deployment of automated testing. In addition, the test environment is isolated from the development environment, which reduces the impact of environmental factors on the test results, thereby improving the reliability and accuracy of the test results. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 An application environment diagram of a test method for an interpreter in one embodiment; Figure 2 A schematic diagram of a flow chart of a method for testing an interpreter in one embodiment; Figure 3 is a flow chart of a method for testing an interpreter in another embodiment; Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0017] The test method of the interpreter provided in the embodiment of the present application can be applied to Figure 1In the application environment shown, and through the interaction between the terminal 102 and the server 104. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 is used to obtain the user's test requirements. The server 104 is used to determine the target test function in the local interpreter environment according to the test requirements; load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module. The server 104 is also used to receive the test results obtained when the remote interpreter executes the target script, and display the determined test results on the terminal 102 according to the type of the target test function. Among them, the terminal 102 can be, but is not limited to, various personal computers, smart phones, drone equipment, smart vehicle-mounted equipment, portable wearable devices, etc. Server 104 is implemented by an independent server or a server cluster composed of multiple servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0018] In one embodiment, Figure 2 As shown, a test method for an interpreter is provided, and the method is applied to a computer device as an example for explanation. The computer device includes Figure 1 The terminal and server in the embodiment include the following steps: Step 202, determining a target test function in a local interpreter environment according to the requirements to be tested.
[0019] An interpreter, such as the Python interpreter, is a program that runs Python code. It can directly execute Python code or compile Python code into machine code. In the Python interpreter, a test function usually refers to a simple function or code snippet used to verify the correctness of the code. These tests can be print statements, assertions, unit tests, or other forms of verification.
[0020] Specifically, the requirements to be tested are associated with key methods in different programming libraries and frameworks for executing core functions. Usually, some software with built-in interpreters have script editing functions, and some specific functions can be achieved by editing and encapsulating customized key methods. Therefore, for this type of software, it is necessary to test whether the key methods provided during editing can be used normally, that is, the process of testing the interpreter based on the requirements to be tested. The computer device can provide an interface, and the user can directly add the function file name parameter in the interface to limit the type of function to be executed according to the requirements to be tested, or directly select the function name to execute the corresponding target test function, so that the target test function can be run on the local interpreter environment.
[0021] In one embodiment, the target test function is a pytest test function based on the Python test framework, which provides rich functions to support simple unit tests and complex functional tests.
[0022] In one embodiment, the computer device pre-encapsulates key methods of various use cases in a key method module (Keyword).
[0023] In one embodiment, a target test function in a local interpreter environment is determined according to the test requirements, including: determining a corresponding file name parameter according to the test requirements triggered by a user response; and performing a function call according to the file name parameter to obtain a target test function.
[0024] Specifically, the test case module (Testcase) in the computer device has encapsulated various test function objects associated with key methods, such as pytest function objects, that is, each key method can correspond to a test function, and the file name parameters are used to correspond one to one. For example, test_besselk_function is a test function that corresponds to the test besselk key method. Therefore, the computer device determines the corresponding file name parameter after responding to the test requirement triggered by the user's selection, and then makes a function call based on the file name parameter to determine the target test function corresponding to each test requirement, and then the test result of the target test function can be executed separately. At the same time, the test process of all or different types of target test functions can also be executed in batches according to the file name parameter. Among them, when performing batch testing, it is only necessary to add an identifier such as "-k" after the startup program and add the file name parameter.
[0025] In this embodiment, the file name parameter is dynamically determined according to user needs and the function call is performed, and each file name parameter corresponds to a related test function separately, which can flexibly and accurately execute the test function to adapt to different test scenarios and needs. Users only need to add simple identifiers and parameters when starting the program to automatically process multiple test tasks, which greatly improves the flexibility of function automation testing.
[0026] Step 204, load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module.
[0027] Among them, the communication module is the execnet module that realizes communication and code execution between multiple interpreters. The execnet module is a distributed computing library based on Python programs. It provides a method to interact with Python interpreters across versions, platforms and network barriers.
[0028] Specifically, the script module (function Testscript) for testing built-in key methods in the computer device pre-stores test scripts for various methods. For example, the test class is the Mathematics TestScript class, and the corresponding key method is the test script for elementary mathematics methods. Therefore, the computer device pre-classifies and saves the scripts in the class attributes of the script module, and then directly and quickly loads the target script corresponding to the target test function from the script module, which improves the convenience of maintaining and updating the test script. The computer device creates a gateway to the remote interpreter after specifying a gateway type and corresponding parameters through the communication module. After the gateway is successfully created, the code method can be used to execute Python code in the remote interpreter, and then a channel object is returned, through which data such as the target script is sent, and data such as test results are received.
[0029] Step 206, receiving the test results obtained when the remote interpreter executes the target script, and displaying the test results according to the type of the target test function.
[0030] Specifically, after receiving the target script, the remote interpreter will perform corresponding operations according to the instructions of the target script, such as calling functions, performing calculations, processing data, etc. After the script is executed, the output test results will be generated. These output test results can be captured through the channel object returned by the code method, and then the test results are returned to the local interpreter through the channel. The local interpreter displays the function test results in the test report according to the type of the target test function through, for example, the allure decorator, so that the stability of the function can also be more intuitive. For example, discrete methods such as the factor method and the gcd method are displayed under discrete methods, polynomial methods such as the poly method and the conv method are displayed in the polynomial method, and the gcd method is used to calculate the greatest common divisor of two numbers.
[0031] In one embodiment, the local interpreter and the remote interpreter are Python interpreters running on the same terminal or different terminals. Different terminals have different permissions for software such as simulation tests. Therefore, through the interactive characteristics of the local interpreter and the remote interpreter, two interpreters can be run on the same terminal or on different terminals. This allows the automated script runtime environment to be deployed on any cloud, and only the relevant information of the terminal where the software under test with the built-in interpreter is located needs to be configured.
[0032] In the test method of the above-mentioned interpreter, the target test function in the local interpreter environment is determined according to the requirements to be tested, and then the target script corresponding to the target test function is loaded from the script module, and the target script is sent to the remote interpreter through the communication module, so that when the test result obtained when the remote interpreter executes the target script is received, the test result can be displayed according to the type of the target test function. Therefore, by automatically loading the target script from the local interpreter environment to the remote interpreter and executing it, the flexibility of the test environment is greatly improved, and the problem of running the automation script directly through the cross-interpreter feature on some systems without software authorization can be solved, so as to call the interpreter through the authorized system and realize the flexible deployment of automated testing.
[0033] In one embodiment, the image module (Images) in the computer device is used to store images, and different types of images are stored in different folders.
[0034] In one embodiment, the file module (files) in the computer device is used to import various temporary files such as workspace files, various md5 comparison files, etc.
[0035] In one embodiment, a log module (Logs) in a computer device is used to store log information.
[0036] In one embodiment, sending the target script to the remote interpreter through the communication module includes: determining the function class corresponding to the target test function through the key method module; calling the communication module based on the static method to realize sending the target script to the remote interpreter.
[0037] Specifically, the function class inherits the window operation class in the common module; the common module (Common) is used for general common classes and common methods. This module encapsulates the window operation class for global window operations. The window operation class, for example, inherits the WindowOperate class in the common module; the function class is used to define key methods, which include static methods. Therefore, the computer device can directly determine the function class corresponding to the target test function through the key method module, such as the FunctionOpr class, and then call the communication module based on the remote_test_function static method of the remote test to send the target script to the remote interpreter for execution.
[0038] Among them, in programming, static methods are methods that belong to a class rather than an instance (object) of the class. They can be called without creating an object of the class and can be directly referenced using the class name. Public methods are methods that are declared as public in a class and can be accessed and called outside the class. A public method may call one or more key methods to complete a task; a key method of a class may be public or private.
[0039] In this embodiment, the static method allows the test script to run on different terminals or different versions of interpreters, which improves the flexibility and adaptability of the test. In addition, the test can be executed in parallel on multiple remote interpreters, significantly reducing the overall test time.
[0040] In one embodiment, a communication module is called based on a static method to achieve sending of a target script to a remote interpreter, including: calling a communication method in the communication module based on a static method, and establishing a gateway with the remote interpreter through the communication method; defining the communication action with the remote interpreter through a code method corresponding to the gateway instance to achieve sending of the target script.
[0041] Specifically, the computer device pre-creates a gateway to the remote interpreter through the communication method in the communication module, and returns an object, such as the makegateway method of the execnet module; this object represents the connection with the remote interpreter and can be used to execute remote code. The code method corresponding to the gateway instance is called through this object to establish a channel to communicate with the remote interpreter, such as the remote_exec method, that is, receiving messages through receive() and sending messages through send(). After the remote interpreter executes the target script, the channel and the gateway are closed to release resources.
[0042] In this embodiment, executing tests on a remote interpreter can avoid interfering with the local development environment, ensure the independence and isolation of the tests, and also test the behavior of the code in different environments. Through the established gateway and channel, the results and feedback of the remote execution can be obtained in real time, which is helpful for real-time debugging and monitoring of the remote execution process. After the remote interpreter executes the target script, closing the channel and gateway in time can release the occupied resources, avoid resource leakage, and ensure the stability and performance of the system.
[0043] In one embodiment, after loading the target script corresponding to the target test function from the script module, it also includes: loading the environment configuration information corresponding to the test requirement from the configuration module; sending the target script and the environment configuration information to the remote interpreter through the communication module, so that the remote interpreter loads the environment configuration information and executes the target script to obtain the test result.
[0044] The environment configuration information includes at least the configuration module project path, the image base path, the log path, the test report path and the tested software installation path.
[0045] Specifically, after the local interpreter loads the target script required for the function test from the function Testscript script module, it will also load the system's environment configuration information from the configuration module (Conf). Then, the function Testscript script module loads the target script required for the function test and the configuration module (Conf) loads the system's environment configuration information and sends it to the remote interpreter through the execnet module. The remote interpreter loads the environment configuration information and executes the target script obtained from the channel associated with the execnet module, so that the remote interpreter loads the environment configuration information and executes the target script, and feeds back the test results to the local interpreter from the channel associated with the execnet module.
[0046] In one embodiment, a configuration module (Conf) in a computer device is used to configure various environmental information.
[0047] In one embodiment, the remote interpreter loads the environment configuration information and executes the target script to obtain the test result, including: preliminarily verifying whether the output of the target script meets expectations through assertion statements; when all assertions in the target script pass, loading the environment configuration information through the target test framework and executing the target script to obtain the test result.
[0048] Specifically, when running a test script, you can use assert statements to verify whether the output of the function in the target script meets expectations. If an assertion fails, that is, the actual output does not match the expected output, the script will display an error message and terminate; if all assertions in the script pass, the script will end normally. For more complex tests, you can use Python test frameworks such as pytest to load environment configuration information and execute the target script. These frameworks provide a wealth of tools and methods to organize and run tests, as well as generate test results.
[0049] In this embodiment, through assertions and test frameworks respectively, errors and problems can be discovered more accurately in the early stages of development, thereby reducing the cost of later repairs. In addition, the test framework supports automated testing and can quickly execute a large number of test cases, thereby improving the execution efficiency of target script tests.
[0050] In one embodiment, Figure 3 As shown, Figure 3 It is a flow chart of the test method of the interpreter in another embodiment. The specific process includes: calling the pytest program through the local Python interpreter, and then loading the target script required for the function test and the environment configuration information of the remote Python interpreter. The target script and the environment configuration information are sent to the remote Python interpreter through the execnet module, so that the remote interpreter loads the environment configuration information and executes the target script. The remote Python interpreter feeds back the test results to the local Python interpreter through the execnet module, so that the local Python interpreter reports and displays the test results.
[0051] In the above embodiment, the interpreter-based test method constitutes an automated test framework in a computer device. This framework is used for editor-type software that integrates a python interpreter, wherein the Pytest test function is combined with the execnet module, the function name of the pytest test function corresponds to the method to be tested, and the target script is saved in the type function class as a class attribute call. The Pytest test function calls the method encapsulated by the execnet module to send the target script to the remote python interpreter, and feeds back the execution result to the local python interpreter, providing a method call scenario that is as realistic as possible for testing the built-in key methods of these software.
[0052] Therefore, for some software that requires authorized encryption, under this framework, the automated test scripts for built-in key methods do not have to be run on the terminal authorized to install the software. An automated test framework can be built on an unauthorized terminal to run these automated test scripts for built-in key methods, and the test results can be returned after the method is called on the authorized terminal in a cross-interpreter manner, thereby eliminating the need to build an automated test framework on the authorized terminal, reducing resource allocation costs.
[0053] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0054] Based on the same inventive concept, the embodiment of the present application also provides a test device for an interpreter for implementing the test method for the interpreter involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiment of the test device for one or more interpreters provided below can refer to the limitations of the test method for the interpreter above, and will not be repeated here.
[0055] In one embodiment, a test device for an interpreter is provided, comprising: a test function determination module, a target script sending module and a test result display module, wherein: The test function determination module is used to determine the target test function in the local interpreter environment according to the requirements to be tested.
[0056] The target script sending module is used to load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module.
[0057] The test result display module is used to receive the test results obtained when the remote interpreter executes the target script, and display the test results according to the type of the target test function.
[0058] Each module in the test of the above-mentioned interpreter can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0059] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store group test results. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a test method for an interpreter is implemented.
[0060] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0061] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0062] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0063] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0064] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0065] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0066] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for testing an interpreter, characterized in that: Applied in the local interpreter, including: Determine the target test function in the local interpreter environment according to the requirements to be tested; Loading a target script corresponding to the target test function from a script module, and sending the target script to a remote interpreter through a communication module; Receive the test results obtained when the remote interpreter executes the target script, and display the test results according to the type of the target test function.
2. The method according to claim 1, characterized in that Determining the target test function in the local interpreter environment according to the requirements to be tested includes: Determine the corresponding file name parameters according to the test requirements triggered by the user response; the test requirements are associated with key methods in different programming libraries and frameworks for executing core functions; A function call is performed according to the file name parameter to obtain a target test function.
3. The method according to claim 1, characterized in that The step of sending the target script to a remote interpreter through a communication module comprises: Determine the function class corresponding to the target test function through the key method module; the function class inherits the window operation class in the common module; the function class is used to define the key method, and the key method includes a static method; The communication module is called based on the static method to send the target script to the remote interpreter.
4. The method according to claim 3, characterized in that The calling of the communication module based on the static method to send the target script to the remote interpreter includes: Calling a communication method in a communication module based on the static method, and establishing a gateway with the remote interpreter through the communication method; The communication action between the gateway instance and the remote interpreter is defined through the code method corresponding to the gateway instance to achieve the sending of the target script.
5. The method according to claim 1, characterized in that After the target script corresponding to the target test function is loaded from the script module, the method further includes: Loading the environment configuration information corresponding to the requirement to be tested from the configuration module; the environment configuration information at least includes the configuration module project path, image base path, log path, test report path and tested software installation path; The target script and the environment configuration information are sent to the remote interpreter through the communication module, so that the remote interpreter loads the environment configuration information and executes the target script to obtain the test result.
6. The method according to claim 5, characterized in that The process of the remote interpreter loading the environment configuration information and executing the target script to obtain the test result includes: Preliminarily verify whether the output of the target script meets expectations through assertion statements; When all assertions in the target script pass, the environment configuration information is loaded through the target test framework and the target script is executed to obtain a test result.
7. The method according to any one of claims 1 to 6, characterized in that: The local interpreter and the remote interpreter are Python interpreters running on the same terminal or different terminals; the target test function is a pytest test function based on the Python test framework; the communication module is an execnet module that realizes communication and code execution between multiple interpreters, and the execnet module is a distributed computing library based on Python programs.
8. A test device for an interpreter, characterized in that: The device comprises: A test function determination module, used to determine a target test function in the local interpreter environment according to a requirement to be tested; A target script sending module is used to load the target script corresponding to the target test function from the script module, and send the target script to the remote interpreter through the communication module; The test result display module is used to receive the test result obtained when the remote interpreter executes the target script, and display the test result according to the type of the target test function.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
