|
12 | 12 | # otherwise use the software for commercial activities involving the Arduino
|
13 | 13 | # software without disclosing the source code of your own applications. To purchase
|
14 | 14 | # a commercial license, send an email to [email protected].
|
15 |
| -import os |
16 |
| -import platform |
17 | 15 | import zipfile
|
18 | 16 | from pathlib import Path
|
19 | 17 |
|
20 |
| -import pytest |
21 | 18 |
|
22 |
| -from test.common import running_on_ci |
23 |
| - |
24 |
| - |
25 |
| -@pytest.mark.skipif( |
26 |
| - running_on_ci() and platform.system() == "Windows", |
27 |
| - reason="Test disabled on Github Actions Win VM until tmpdir inconsistent behavior bug is fixed", |
28 |
| -) |
29 | 19 | def test_sketch_new(run_command, working_dir):
|
30 | 20 | # Create a test sketch in current directory
|
31 | 21 | current_path = working_dir
|
32 | 22 | sketch_name = "SketchNewIntegrationTest"
|
33 |
| - current_sketch_path = os.path.join(current_path, sketch_name) |
34 |
| - result = run_command("sketch new {}".format(sketch_name)) |
| 23 | + current_sketch_path = Path(current_path, sketch_name) |
| 24 | + result = run_command(f"sketch new {sketch_name}") |
35 | 25 | assert result.ok
|
36 |
| - assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
37 |
| - assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 26 | + assert f"Sketch created in: {current_sketch_path}" in result.stdout |
| 27 | + assert Path(current_sketch_path, f"{sketch_name}.ino").is_file() |
38 | 28 |
|
39 | 29 | # Create a test sketch in current directory but using an absolute path
|
40 | 30 | sketch_name = "SketchNewIntegrationTestAbsolute"
|
41 |
| - current_sketch_path = os.path.join(current_path, sketch_name) |
42 |
| - result = run_command("sketch new {}".format(current_sketch_path)) |
| 31 | + current_sketch_path = Path(current_path, sketch_name) |
| 32 | + result = run_command(f'sketch new "{current_sketch_path}"') |
43 | 33 | assert result.ok
|
44 |
| - assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
45 |
| - assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 34 | + assert f"Sketch created in: {current_sketch_path}" in result.stdout |
| 35 | + assert Path(current_sketch_path, f"{sketch_name}.ino").is_file() |
46 | 36 |
|
47 | 37 | # Create a test sketch in current directory subpath but using an absolute path
|
48 | 38 | sketch_name = "SketchNewIntegrationTestSubpath"
|
49 |
| - sketch_subpath = os.path.join("subpath", sketch_name) |
50 |
| - current_sketch_path = os.path.join(current_path, sketch_subpath) |
51 |
| - result = run_command("sketch new {}".format(sketch_subpath)) |
| 39 | + sketch_subpath = Path("subpath", sketch_name) |
| 40 | + current_sketch_path = Path(current_path, sketch_subpath) |
| 41 | + result = run_command(f"sketch new {sketch_subpath}") |
52 | 42 | assert result.ok
|
53 |
| - assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
54 |
| - assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 43 | + assert f"Sketch created in: {current_sketch_path}" in result.stdout |
| 44 | + assert Path(current_sketch_path, f"{sketch_name}.ino").is_file() |
55 | 45 |
|
56 | 46 | # Create a test sketch in current directory using .ino extension
|
57 | 47 | sketch_name = "SketchNewIntegrationTestDotIno"
|
58 |
| - current_sketch_path = os.path.join(current_path, sketch_name) |
59 |
| - result = run_command("sketch new {}".format(sketch_name + ".ino")) |
| 48 | + current_sketch_path = Path(current_path, sketch_name) |
| 49 | + result = run_command(f"sketch new {sketch_name}.ino") |
60 | 50 | assert result.ok
|
61 |
| - assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
62 |
| - assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 51 | + assert f"Sketch created in: {current_sketch_path}" in result.stdout |
| 52 | + assert Path(current_sketch_path, f"{sketch_name}.ino").is_file() |
63 | 53 |
|
64 | 54 |
|
65 | 55 | def verify_zip_contains_sketch_excluding_build_dir(files):
|
|
0 commit comments