CN111309615A - Pycharm-based code selection execution method, device, equipment and storage medium - Google Patents

Pycharm-based code selection execution method, device, equipment and storage medium Download PDF

Info

Publication number
CN111309615A
CN111309615A CN202010098679.8A CN202010098679A CN111309615A CN 111309615 A CN111309615 A CN 111309615A CN 202010098679 A CN202010098679 A CN 202010098679A CN 111309615 A CN111309615 A CN 111309615A
Authority
CN
China
Prior art keywords
code
executed
execution
pycharm
line number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010098679.8A
Other languages
Chinese (zh)
Inventor
杨磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Suishou Jinfu Information Technology Co ltd
Original Assignee
Shenzhen Suishou Jinfu Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Suishou Jinfu Information Technology Co ltd filed Critical Shenzhen Suishou Jinfu Information Technology Co ltd
Priority to CN202010098679.8A priority Critical patent/CN111309615A/en
Publication of CN111309615A publication Critical patent/CN111309615A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The embodiment of the invention discloses a code selection execution method, a device, equipment and a storage medium based on Pycharm, wherein the method comprises the following steps: acquiring an execution command; analyzing parameters transmitted by the execution command; extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm; splicing the code to be executed and preset content and then writing the spliced code to a temporary file; and executing the code to be executed according to the temporary file. The embodiment of the invention realizes the function of selectively executing the Python code written in Pycharm, so that a user can flexibly select the code content to be tested when carrying out UI test, the flexibility and the convenience of the UI test are improved, the test workload of the user is reduced, and the test efficiency of the user is improved.

Description

Pycharm-based code selection execution method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a code selection execution method, device, equipment and storage medium based on Pycharm.
Background
Pychar is a Python IDE (Integrated development Environment) with a complete set of tools that can help users improve their efficiency when developing using Python language, such as debugging, syntax highlighting, Project management, code hopping, intelligent prompting, autocompletion, unit testing, version control, etc.
Generally, a user needs to perform a ui (user interface) test on the written code to determine whether the written code functions normally. However, when a user writes a Python code by using PyCharm, if only a certain code section in the whole code section has an error or needs to verify whether the function of the certain code section is normal, the whole code section still needs to be tested to obtain a test result, so that the code without the error is also tested, and the test time is prolonged. The user can only test the code with the error, but the user needs to annotate other codes without the error, namely, the codes without the error are annotated, so that the computer does not execute the annotated codes without the error during testing, and the line-by-line annotation not only increases the workload of the user, but also increases the testing time.
Disclosure of Invention
In view of this, embodiments of the present invention provide a PyCharm-based code selection execution method, apparatus, device, and storage medium, so as to implement a test function directly executed on a selected code without annotating the code.
In a first aspect, an embodiment of the present invention provides a PyCharm-based code selection execution method, including:
acquiring an execution command;
analyzing parameters transmitted by the execution command;
extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
splicing the code to be executed and preset content and then writing the spliced code to a temporary file;
and executing the code to be executed according to the temporary file.
Further, the parameters include: execution mode, script path, head line number, and tail line number.
Further, the extracting the code to be executed according to the parameters includes:
determining a storage position of a code to be executed according to the script path;
and extracting the code to be executed from the storage position according to the head line number and the tail line number.
Further, executing the code to be executed according to the temporary file includes:
organizing a test case according to the temporary file;
and executing the test case according to the execution mode, wherein the effective statement of the test case comprises the code to be executed.
Further, before the obtaining the execution command, the method further includes:
judging whether a trigger instruction for selecting execution is received;
and if the trigger instruction is received, generating an execution command.
In a second aspect, an embodiment of the present invention provides a PyCharm-based code selection execution apparatus, including:
the execution command acquisition module is used for acquiring an execution command;
the execution command analysis module is used for analyzing the parameters transmitted by the execution command;
the code extraction module is used for extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
the temporary file generation module is used for splicing the code to be executed and preset content to generate a temporary file;
and the code execution module is used for executing the code to be executed according to the temporary file.
Further, the parameters include: execution mode, script path, head line number, and tail line number.
Further, the code extraction module is specifically configured to:
determining a storage position of a code to be executed according to the script path;
and extracting the code to be executed from the storage position according to the head line number and the tail line number.
In a third aspect, an embodiment of the present invention provides a computer device, where the computer device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the PyCharm-based code selection execution method provided by any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the PyCharm-based code selection execution method provided in any embodiment of the present invention.
The code selection execution method based on Pycharm provided by the embodiment of the invention obtains the execution command; analyzing parameters transmitted by the execution command; extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm; splicing the code to be executed and preset content and then writing the spliced code to a temporary file; and executing the code to be executed according to the temporary file. The selection execution function of the Python code written in the Pycharm is realized, so that a user can flexibly select the code content to be tested when the user performs the UI test, the flexibility and the convenience of the UI test are improved, the test workload of the user is reduced, and the test efficiency of the user is improved.
Drawings
Fig. 1 is a schematic flowchart of a PyCharm-based code selection execution method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a PyCharm-based code selection execution method according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of a test case according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a PyCharm-based code selection execution apparatus according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the steps as a sequential process, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps may be rearranged. A process may be terminated when its operations are completed, but may have additional steps not included in the figure. A process may correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
Furthermore, the terms "first," "second," and the like may be used herein to describe various orientations, actions, steps, elements, or the like, but the orientations, actions, steps, or elements are not limited by these terms. These terms are only used to distinguish one direction, action, step or element from another direction, action, step or element. The terms "first", "second", etc. are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "plurality", "batch" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Example one
Fig. 1 is a flowchart illustrating a code selection execution method based on PyCharm according to an embodiment of the present invention, which is applicable to selecting a certain section of code written in PyCharm to directly execute a test function. As shown in fig. 1, a PyCharm-based code selection execution method according to an embodiment of the present invention includes:
and S110, acquiring an execution command.
Specifically, the selected execution (Run Select) is to execute a selected section of code. The execution command is a command that the user selects to execute a certain code written in PyCharm after selecting the code.
And S120, analyzing the parameters transmitted by the execution command.
Specifically, the parameters passed by the execution command are used to determine the location and specific content of the code to be executed, including but not limited to: execution mode, script path, head line number, and tail line number. The execution mode may include a normal mode and a debug mode, the normal mode refers to a mode for executing the code normally, and in the mode, the whole code is executed from top to bottom in sequence; the debug mode is a mode corresponding to the selected execution function, and only the code to be executed selected by the user is executed in the debug mode. The script path is a storage path of the script file where the code to be executed selected by the user is located, the first line number represents a starting line number of the code to be executed selected by the user in the script file, and the last line number represents a last line number of the code to be executed selected by the user in the script file.
S130, extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm.
Specifically, the position and specific content of the code to be executed can be determined according to the parameters transmitted by the execution command, so that the code to be executed can be extracted. The code to be executed in the application is written by a code writing tool Pycharm developed by Python.
And S140, splicing the code to be executed and the preset content and writing the spliced code to a temporary file.
Specifically, a single section of code to be executed cannot be directly executed by the computer, and it also needs to form a complete test flow with other codes, and the computer executes the test flow, that is, executes the section of code to be executed. A complete Test flow is also called a Test Case (Test Case), and mainly comprises a Class (Class), a set Up (set Up) of a pre-Test environment, an execution Test code (Test) and a restore (wear Down) of a post-Test environment, and the preset content comprises all contents except the execution Test code (Test) in the Test Case. Splicing the code to be executed with the preset content, namely splicing the content of the code to be executed as an execution test code (test) in the test case with the preset content, so that the code to be executed and the preset content form a complete executable test flow, and writing the complete executable test flow into a temporary file for storage.
And S150, executing the code to be executed according to the temporary file.
Specifically, the content of the temporary file is read, and the temporary file is executed as a test case, and since the code to be executed is included in the test case, executing the test case is equivalent to executing the code to be executed.
The code selection execution method based on Pycharm provided by the embodiment of the invention comprises the steps of obtaining an execution command; analyzing parameters transmitted by the execution command; extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm; splicing the code to be executed and preset content and then writing the spliced code to a temporary file; and executing the code to be executed according to the temporary file. The selection execution function of the Python code written in the Pycharm is realized, so that a user can flexibly select the code content to be tested when the user performs the UI test, the flexibility and the convenience of the UI test are improved, the test workload of the user is reduced, and the test efficiency of the user is improved.
Example two
Fig. 2 is a flowchart illustrating a PyCharm-based code selection execution method according to a second embodiment of the present invention, which is a further refinement of the above embodiments. As shown in fig. 2, a PyCharm-based code selection execution method according to a second embodiment of the present invention includes:
s210, judging whether a trigger instruction for selecting execution is received.
And S220, if the trigger instruction is received, generating an execution command.
Specifically, when a user needs to perform selective execution on a certain code, on a code editing page of PyCharm, a code to be executed is selected through a mouse, then a shortcut key is pressed down, and a trigger instruction for selective execution is generated.
It should be noted that the manner in which the user sends the trigger command by pressing the shortcut key is implemented by an External Tools function provided by PyCharm.
And S230, acquiring an execution command.
Specifically, the selected execution (Run Select) is to execute a selected section of code. The execution command is a command that the user selects to execute a certain code written in PyCharm after selecting the code.
S240, analyzing parameters transmitted by the execution command, wherein the parameters comprise: execution mode, script path, head line number, and tail line number.
Specifically, the parameters passed by the execution command are used to determine the location and specific content of the code to be executed, including but not limited to: execution mode, script path, head line number, and tail line number. The execution mode may include a normal mode and a debug mode, the normal mode refers to a mode for executing the code normally, and in the mode, the whole code is executed from top to bottom in sequence; the debug mode is a mode corresponding to the selected execution function, and only the code to be executed selected by the user is executed in the debug mode. The script path is a storage path of the script file where the code to be executed selected by the user is located, the first line number represents a starting line number of the code to be executed selected by the user in the script file, and the last line number represents a last line number of the code to be executed selected by the user in the script file.
And S250, determining the storage position of the code to be executed according to the script path.
Specifically, the storage location of the script file where the code to be executed is located can be determined according to the script path, that is, the storage location of the code to be executed is also determined.
S260, extracting the code to be executed from the storage position according to the head line number and the tail line number.
Specifically, the content extracted according to the head line number and the tail line number includes a whole line code corresponding to the head line number up to a whole line code corresponding to the tail line number, for example, if the head line number is 6 and the tail line number is 8, the extracted content is a code of 3 lines from line 6 to line 8 in the script file. It should be noted that the extracted content is the minimum unit of a line of codes, and if the user selects only a part of codes in a line of codes, all the codes corresponding to the line are still extracted.
And S270, splicing the code to be executed and the preset content and writing the spliced code to a temporary file.
Specifically, a single section of code to be executed cannot be directly executed by the computer, and it also needs to form a complete test flow with other codes, and the computer executes the test flow, that is, executes the section of code to be executed. A complete Test flow is also called a Test Case (Test Case), and mainly comprises a Class (Class), a set Up (set Up) of a pre-Test environment, an execution Test code (Test) and a restore (wear Down) of a post-Test environment, and the preset content comprises all contents except the execution Test code (Test) in the Test Case. Splicing the code to be executed with the preset content, namely splicing the content of the code to be executed as an execution test code (test) in the test case with the preset content, so that the code to be executed and the preset content form a complete executable test flow, and writing the complete executable test flow into a temporary file for storage.
And S280, organizing the test case according to the temporary file.
Specifically, the step of organizing the test case is to read the temporary file, and use the temporary file as a script file of the test case to perform the test, and obviously, the content of the temporary file is the same as that of the test case.
S290, executing the test case according to the execution mode, wherein the effective statement of the test case comprises the code to be executed.
Specifically, the test case is executed according to the debug mode, and the valid statement of the test case is the code actually executed in the test case. For example, fig. 3 illustrates a schematic diagram of a test case, where the test case includes Class 20, setUp30, tear Down 40, tear 50, and to-be-executed code 60, where Class 20, set Up30, tear Down 40, and tear 50 are preset contents, the content of test50 is to-be-executed code 60, and the contents of set Up30 and tear Down 40 are both set to pass (skip), then a valid statement in the test case is to-be-executed code 60, and executing the test case is equivalent to executing the to-be-executed code 60.
The PyCharm-based code selective execution method provided by the embodiment of the invention realizes the selective execution function of Python codes written in PyCharm, and the codes to be executed are executed as effective statements of a test case, so that the codes to be executed selected by a user can be used as a function with a certain function, the user can write codes of a plurality of functions in a script file, when the functions of a certain function need to be used, the corresponding codes are selected to perform selective execution operation, the number of the script files is reduced, the code calling is convenient, and the test efficiency of the user is improved.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a PyCharm-based code selection execution device according to a third embodiment of the present invention, which is applicable to selecting a certain section of code written in PyCharm to directly execute a test function. The PyCharm-based code selection execution device provided in this embodiment may implement the PyCharm-based code selection execution method provided in any embodiment of the present invention, and has a corresponding functional structure and beneficial effects of the implementation method, and reference may be made to the description of any method embodiment of the present invention for details that are not described in detail in this embodiment.
As shown in fig. 4, a PyCharm-based code selection execution apparatus according to a third embodiment of the present invention includes: an execution command acquisition module 310, an execution command parsing module 320, a code extraction module 330, a temporary file generation module 340, and a code execution module 350.
The execution command obtaining module 310 is configured to obtain an execution command;
the execution command analysis module 320 is used for analyzing the parameters transmitted by the execution command;
the code extraction module 330 is configured to extract a code to be executed according to the parameter, where the code to be executed is written by PyCharm;
the temporary file generating module 340 is configured to splice the code to be executed with preset content and then generate a temporary file;
the code execution module 350 is configured to execute the code to be executed according to the temporary file.
Further, the parameters include: execution mode, script path, head line number, and tail line number.
Further, the code extraction module 330 is specifically configured to: determining a storage position of a code to be executed according to the script path; and extracting the code to be executed from the storage position according to the head line number and the tail line number.
Further, the code execution module 350 is specifically configured to: organizing a test case according to the temporary file; and executing the test case according to the execution mode, wherein the effective statement of the test case comprises the code to be executed.
Further, the system further comprises a trigger instruction receiving module, wherein the trigger instruction receiving module is specifically configured to: judging whether a trigger instruction for selecting execution is received; and if the trigger instruction is received, generating an execution command.
The PyCharm-based code selection execution device provided by the third embodiment of the invention realizes the function of selecting and executing Python codes written in PyCharm through the execution command acquisition module, the execution command analysis module, the code extraction module, the temporary file generation module and the code execution module, so that a user can flexibly select code contents to be tested when the user performs a UI test, the flexibility and the convenience of the UI test are improved, the test workload of the user is reduced, and the test efficiency of the user is improved.
Example four
Fig. 5 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary computer device 412 suitable for use in implementing embodiments of the present invention. The computer device 412 shown in FIG. 5 is only one example and should not impose any limitations on the functionality or scope of use of embodiments of the present invention.
As shown in fig. 5, the computer device 412 is in the form of a general purpose computer device. Components of computer device 412 may include, but are not limited to: one or more processors 416, a storage device 428, and a bus 418 that couples the various system components including the storage device 428 and the processors 416.
Bus 418 represents one or more of any of several types of bus structures, including a memory device bus or memory device controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 412 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by computer device 412 and includes both volatile and nonvolatile media, removable and non-removable media.
Storage 428 may include computer system readable media in the form of volatile Memory, such as Random Access Memory (RAM) 430 and/or cache Memory 432. The computer device 412 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 434 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk such as a Compact disk Read-Only Memory (CD-ROM), Digital Video disk Read-Only Memory (DVD-ROM) or other optical media may be provided. In these cases, each drive may be connected to bus 418 by one or more data media interfaces. Storage 428 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) of program modules 442 may be stored, for instance, in storage 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. The program modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
The computer device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing computer device, display 424, etc.), with one or more computer devices that enable a user to interact with the computer device 412, and/or with any computer device (e.g., network card, modem, etc.) that enables the computer device 412 to communicate with one or more other computer devices. Such communication may occur via input/output (I/O) interfaces 422. Also, computer device 412 may communicate with one or more networks (e.g., a Local Area Network (LAN), Wide Area Network (WAN), and/or a public Network, such as the internet) through Network adapter 420. As shown in FIG. 5, network adapter 420 communicates with the other modules of computer device 412 via bus 418. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the computer device 412, including but not limited to: microcode, computer device drivers, redundant processors, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems, to name a few.
The processor 416 executes various functional applications and data processing by running programs stored in the storage device 428, for example, implementing a PyCharm-based code selection execution method provided by any embodiment of the present invention, which may include:
acquiring an execution command;
analyzing parameters transmitted by the execution command;
extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
splicing the code to be executed and preset content and then writing the spliced code to a temporary file;
and executing the code to be executed according to the temporary file.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a PyCharm-based code selection execution method provided in any embodiment of the present invention, where the method may include:
acquiring an execution command;
analyzing parameters transmitted by the execution command;
extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
splicing the code to be executed and preset content and then writing the spliced code to a temporary file;
and executing the code to be executed according to the temporary file.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or terminal. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A Pycharm-based code selection execution method, comprising:
acquiring an execution command;
analyzing parameters transmitted by the execution command;
extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
splicing the code to be executed and preset content and then writing the spliced code to a temporary file;
and executing the code to be executed according to the temporary file.
2. The method of claim 1, wherein the parameters comprise: execution mode, script path, head line number, and tail line number.
3. The method of claim 2, wherein extracting code to be executed from the parameters comprises:
determining a storage position of a code to be executed according to the script path;
and extracting the code to be executed from the storage position according to the head line number and the tail line number.
4. The method of claim 2, wherein executing the code to be executed according to the temporary file comprises:
organizing a test case according to the temporary file;
and executing the test case according to the execution mode, wherein the effective statement of the test case comprises the code to be executed.
5. The method of claim 1, wherein obtaining the execution command is preceded by:
judging whether a trigger instruction for selecting execution is received;
and if the trigger instruction is received, generating an execution command.
6. A PyCharm-based code selection execution apparatus, comprising:
the execution command acquisition module is used for acquiring an execution command;
the execution command analysis module is used for analyzing the parameters transmitted by the execution command;
the code extraction module is used for extracting a code to be executed according to the parameters, wherein the code to be executed is written by Pycharm;
the temporary file generation module is used for splicing the code to be executed and preset content to generate a temporary file;
and the code execution module is used for executing the code to be executed according to the temporary file.
7. The apparatus of claim 6, wherein the parameters comprise: execution mode, script path, head line number, and tail line number.
8. The apparatus of claim 7, wherein the code extraction module is specifically configured to:
determining a storage position of a code to be executed according to the script path;
and extracting the code to be executed from the storage position according to the head line number and the tail line number.
9. A computer device, the device comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the PyCharm-based code selection execution method of any one of claims 1-5.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the PyCharm-based code selection execution method according to any one of claims 1 to 5.
CN202010098679.8A 2020-02-18 2020-02-18 Pycharm-based code selection execution method, device, equipment and storage medium Pending CN111309615A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010098679.8A CN111309615A (en) 2020-02-18 2020-02-18 Pycharm-based code selection execution method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010098679.8A CN111309615A (en) 2020-02-18 2020-02-18 Pycharm-based code selection execution method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111309615A true CN111309615A (en) 2020-06-19

Family

ID=71158288

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010098679.8A Pending CN111309615A (en) 2020-02-18 2020-02-18 Pycharm-based code selection execution method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111309615A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140013298A1 (en) * 2012-07-06 2014-01-09 International Business Machines Corporation Auto generation and linkage of source code to test cases
CN107305527A (en) * 2016-04-22 2017-10-31 腾讯科技(深圳)有限公司 The treating method and apparatus of code file
CN109218507A (en) * 2017-07-03 2019-01-15 阿里巴巴集团控股有限公司 The methods, devices and systems of task execution

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140013298A1 (en) * 2012-07-06 2014-01-09 International Business Machines Corporation Auto generation and linkage of source code to test cases
CN107305527A (en) * 2016-04-22 2017-10-31 腾讯科技(深圳)有限公司 The treating method and apparatus of code file
CN109218507A (en) * 2017-07-03 2019-01-15 阿里巴巴集团控股有限公司 The methods, devices and systems of task execution

Similar Documents

Publication Publication Date Title
US11151018B2 (en) Method and apparatus for testing a code file
CN110764945B (en) Crash log processing method, device, equipment and storage medium
CN107506300B (en) User interface testing method, device, server and storage medium
CN109522010B (en) Initialization code adding method and device, storage medium and electronic equipment
CN115080398A (en) Automatic interface test system and method
CN113051514A (en) Element positioning method and device, electronic equipment and storage medium
CN111538659B (en) Interface testing method, system, electronic equipment and storage medium of business scene
CN110727476B (en) Method, device, equipment and storage medium for generating authorization configuration file
CN110659210A (en) Information acquisition method and device, electronic equipment and storage medium
CN110597704B (en) Pressure test method, device, server and medium for application program
CN113138937A (en) Test method and device
CN110888641B (en) Script automatic generation method and device, server and storage medium
CN114003269A (en) Component processing method and device, electronic equipment and storage medium
CN113656304A (en) Method and device for testing front-end application program and storage medium
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
CN112988578A (en) Automatic testing method and device
CN110045952B (en) Code calling method and device
CN110716859A (en) Method for automatically pushing test cases for modified codes and related device
CN113805861B (en) Code generation method based on machine learning, code editing system and storage medium
CN111309615A (en) Pycharm-based code selection execution method, device, equipment and storage medium
CN111124423B (en) Compiling detection method, device, server and medium based on multiple platforms
CN114238128A (en) Test case generation method and device, electronic equipment and computer readable medium
KR101476536B1 (en) The method and system for inspecting program
CN113342431A (en) Function call stack backtracking and program exception handling method, device, equipment and medium
CN113656301A (en) Interface testing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination