Test tool development - Python development practice for test engineers

Altruistic heart, throw bricks to attract jade. Compared with an expert in a certain programming language, it may be more necessary for a test development engineer to become a "generalist". In addition to functional testing and automated testing, we also need to learn knowledge in other fields, such as performance testing, data testing, security testing, mobile End testing, etc., and then use Python code to implement some personalized test tool packaging for the team or others to use to maximize the value of the code.

Quality awareness should be the consensus of every software practitioner. The goal of testing is to find the defects in the system as early as possible and make them repaired.

From an economic point of view, the earlier the error is found, the lower the repair cost and risk. Later error repair will not only increase the communication time, but may also introduce new problems, increase the test verification time, and the project will also be delayed. risk. Developers should also have basic testing capabilities to ensure that the code they deliver is usable, which is the minimum requirement for code quality. High-quality software products are the inevitable result of all members of a software team completing their tasks responsibly. Whether it is the self-testing of developers or the special testing of testers, any link that is not done properly will lead to the failure of the final product. quality problems.

From the quality point of view, based on the author's work experience, the practical chapter provides tool code examples in various testing fields and testing professions for reference and reference by developers or testers, so as to meet the testing needs of readers in actual work. The combat chapter has 6 chapters (Chapter 7 to Chapter 12), introducing audio test tool development, custom socket test tool development, interface test tool development, data test tool development, performance test tool development, and security test tool development in sequence , each chapter starts from three aspects: requirement background, related knowledge and code interpretation.

Audio Test Tool Development

Now that short videos are popular, the derived live broadcast industry is also popular, and the quality of audio and video directly affects the audio and video business. Python has many third-party libraries for audio and video processing, which can be used to develop some detection tools. In this chapter, we demonstrate how to perform checksum conversion of MP3 and WAV audio file formats based on Python, mainly from the requirements background, knowledge involved and code interpretation.

demand background

Now image recognition, speech recognition and other projects are becoming more and more popular. The project trains a set of models through machine learning, and then uploads images and audio to the model to realize the recognition of image content and convert audio into text.

But sometimes the model we train may not be perfect, and the format restrictions are relatively strict, such as only accepting pictures in PNG format or audio in MP3 format, etc. At this time, we need to determine the format of the file uploaded by the user. If it is not in an acceptable format, we will directly return the file format error and prompt the user to re-upload the file in the specified format.

Usually, the format judgment cannot be judged by the file extension. We change the file extension of a PNG format image to .jpg, and it can still be displayed normally, but the actual format is still PNG, because the byte stream corresponding to this image There is no change; the same is true for audio files, changing the extension of an audio file in WAV format to .mp3 can also be played, but its format is still WAV.

This chapter will explain the audio file format in depth, and analyze and interpret it with code examples.

knowledge involved

Audio format, that is, music format, refers to the process of digital and analog conversion of audio files to be played or processed in the computer. The audio format has a maximum bandwidth of 20 000 Hz and a rate between 40 and 50 000 Hz. Audio files refer to files that store sound content. The sound waves that can be heard by the human ear range from 20 Hz to 20 000 Hz. Common audio files in work can be divided into three types: uncompressed audio format, lossless compressed audio format and lossy compressed audio format according to the degree of compression, as shown in Table 7-1.

picture

Table 7-1 Audio classification

Among all audio formats, it is recommended to use files stored in uncompressed audio formats first. As the name suggests, these audio files are essentially uncompressed. That is, it simply converts real-world sound waves into a digital format without any processing on them. The biggest advantage of the uncompressed audio format is that it is real and can retain the detailed information of the recorded audio, but it needs to occupy a large storage space.

Uncompressed audio files can take up a lot of space, so we recommend compressing them before storing them. Using lossless compression technology with advanced algorithms, users can preserve the original data while reducing the file size. Ideally, a lossless compression technique would reduce the file size to 1/2 to 1/5 while still retaining the original data.

In daily life, most people don't want music files to take up a lot of device space, so people often use lossy audio formats. Using lossy compression technology can greatly reduce the file size, but the original data of the audio is also damaged, and sometimes music files stored in this format will not even sound like the original audio.

For a deeper understanding of audio files, here are some important core concepts.

  • Sampling: The wave is infinitely smooth, and the process of sampling is to extract the frequency value of certain points from the wave, which is to digitize the analog signal.

  • Sampling frequency: also known as sampling rate, refers to the number of samples or samples that the recording device samples the sound signal per unit time, the unit is Hz (Hertz), the higher the sampling frequency, the larger the frequency range that can be expressed, and the better the sound restoration The more real and natural, of course the greater the amount of data. The sampling rate of a general music CD is 44 100 Hz, so it is completely sufficient to keep the audio sampling rate in video encoding at this level, and usually the video converter also uses this sampling rate as the default setting.

  • Sampling bits: the range of data that each sampling point can represent. The number of sampling bits usually has 8 bits or 16 bits. The larger the number of sampling bits, the more delicate the change of the sound that can be recorded, and the larger the corresponding amount of data.

  • Number of channels: The number of channels refers to the number of speakers that support different sounds, and it is one of the important indicators to measure audio equipment.

  • Pulse code modulation (PCM): The process of sampling and quantizing sound without any encoding or compression.

  • Encoding: The sampled and quantized signal is not yet a digital signal. The process of converting the sampled and quantized signal into a digitally encoded pulse is called encoding. The binary sequence formed by analog audio after sampling, quantization, and encoding is a digital audio signal.

  • Code rate (bit rate): The amount of information that can pass per second in a data stream, in bit/s (bit per second). For example, common MP3 bit rates are 128 000 bit/s, 160 000 bit/s, 320 000 bit/s, etc. The higher the bit rate, the better the sound quality. The data in MP3 is composed of ID3 and audio data, wherein ID3 is used to store common information such as song title, singer, album, and audio track. In addition, code rate = sampling rate × number of sampling bits × number of channels.

hint

The frequency range of normal human hearing is 20-20 000 Hz. According to the Nyquist sampling theorem, in order to ensure that the sound is not distorted, the sampling frequency should be around 40-000 Hz. Commonly used audio sampling frequencies are 8 000 Hz, 11 025 Hz, 22 050 Hz, 16 000 Hz, 37 800 Hz, 44 100 Hz, 48 000 Hz, etc. If a higher sampling frequency is used, the sound quality of DVD can also be achieved.

Finally: The complete software testing video tutorial below has been sorted out and uploaded, and friends who need it can get it by themselves [Guaranteed 100% free]

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

Guess you like

Origin blog.csdn.net/wx17343624830/article/details/132676157