小编W2a*_*W2a的帖子

pytest - 如何使其递归搜索?

我有以下tests目录树:

tests/
  subfolder_1/
    test_1.py
  subfolder_2/
    subsubfolder/
      subsubsubfolder/
        test_2.py
Run Code Online (Sandbox Code Playgroud)

py.test 只找到test_1.py. 我怎样才能让它找到test_2.py

python pytest python-3.x

9
推荐指数
2
解决办法
5312
查看次数

屏幕捕获无法使用C++和GDI捕获整个屏幕

我通过网络进行了一些研究,发现了一些有用的代码.我改变了一下,试图捕获整个屏幕并生成一个我可以通过udp数据包发送的缓冲区:

#include <iostream>
#include <Windows.h>
#include <fstream>

void CapruteScreenAndSaveToFile()
{
    uint16_t BitsPerPixel = 24;
    uint32_t Width = GetSystemMetrics(SM_CXSCREEN);
    uint32_t Height = GetSystemMetrics(SM_CYSCREEN);

    // Create Header
    BITMAPFILEHEADER Header;
    memset(&Header, 0, sizeof(Header));
    Header.bfType = 0x4D42;
    Header.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);

    // Create Info
    BITMAPINFO Info;
    memset(&Info, 0, sizeof(Info));
    Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    Info.bmiHeader.biWidth = Width;
    Info.bmiHeader.biHeight = Height;
    Info.bmiHeader.biPlanes = 1;
    Info.bmiHeader.biBitCount = BitsPerPixel;
    Info.bmiHeader.biCompression = BI_RGB;
    Info.bmiHeader.biSizeImage = Width * Height * (BitsPerPixel > 24 ? 4 : 3);

    // Capture screen …
Run Code Online (Sandbox Code Playgroud)

c++ winapi gdi

4
推荐指数
1
解决办法
676
查看次数

pytest-mock:模拟一个抽象类

我正在尝试使以下代码起作用:

from pytest_mock import mocker

class TestClass(mocker):
  def setup_method(self):
    self.some_mock = SomeAbstractClass()
    self.testsubject = ClassThatIsBeingTested(self.some_mock)

  def test_1(self):
    mocker.patch(self.some_mock, 'some_function', return_value=5)
    assert 5 == self.testsubject.function_that_internally_uses_the_mock()
Run Code Online (Sandbox Code Playgroud)

但我得到一个 TypeError因为尝试实例化一个抽象类。

我怎么能嘲笑SomeAbstractClass

python pytest python-3.x

4
推荐指数
1
解决办法
2435
查看次数

C++ one liner for"由数字组成的字符串"

我正在寻找一个短(和快)代码来检查一个字符串是否只包含数字,特别是寻找一个衬里.这是我的临时代码:

bool IsNumber(const std::string& str)
{
    int i = 0;
    for( ; i<str.size() && isdigit(str[i]); ++i);

    return ( i == str.size() );
}
Run Code Online (Sandbox Code Playgroud)

c++ c++11

1
推荐指数
1
解决办法
174
查看次数

如何在 amd64 中正确转储 IDT 条目?

以下代码:

标题:

// InterruptDescriptorTable.h

#define MAX_IDT_ENTRIES 256

#define MAKELONG(a, b)  ((unsigned long) (((unsigned short)(a)) | ((unsigned long) ((unsigned) (b))) << 16 ))

/* SIDT returns IDT in following format */
#pragma pack(1)
typedef struct
{
    unsigned short IDTLimit;
    unsigned short LowIDTBase;
    unsigned short HighIDTBase;

} s_idt_info;
#pragma pack()

/* entry in IDT ( interrupt gate ) */
#pragma pack(1)
typedef struct
{
    unsigned short LowOffset;
    unsigned short selector;
    unsigned char unused_lo;
    unsigned char segment_type:4;
    unsigned char system_segment_flag:1;
    unsigned char DPL:2; …
Run Code Online (Sandbox Code Playgroud)

c windows x86 kernel

0
推荐指数
1
解决办法
607
查看次数

标签 统计

c++ ×2

pytest ×2

python ×2

python-3.x ×2

c ×1

c++11 ×1

gdi ×1

kernel ×1

winapi ×1

windows ×1

x86 ×1