Skip to content

Commit 9b9c692

Browse files
committedMar 1, 2016
Syntax highlighting for processing tests readme
1 parent e695fbb commit 9b9c692

File tree

1 file changed

+78
-58
lines changed

1 file changed

+78
-58
lines changed
 

‎python/plugins/processing/tests/README.md

Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ This file is structured with [yaml syntax](http://www.yaml.org/start.html).
77

88
A basic test appears under the toplevel key `tests` and looks like this:
99

10-
- name: centroid
11-
algorithm: qgis:polygoncentroids
12-
params:
13-
- type: vector
14-
name: polys.gml
15-
results:
16-
OUTPUT_LAYER:
17-
type: vector
18-
name: expected/polys_centroid.gml
10+
```yaml
11+
- name: centroid
12+
algorithm: qgis:polygoncentroids
13+
params:
14+
- type: vector
15+
name: polys.gml
16+
results:
17+
OUTPUT_LAYER:
18+
type: vector
19+
name: expected/polys_centroid.gml
20+
```
1921
2022
How To
2123
------
@@ -39,16 +41,18 @@ ones to params and the last one(s) to results.
3941

4042
The above translates to
4143

42-
- name: densify
43-
algorithm: qgis:densifygeometriesgivenaninterval
44-
params:
45-
- type: vector
46-
name: polys.gml
47-
- 2 # Interval
48-
results:
49-
OUTPUT:
50-
type: vector
51-
name: expected/polys_densify.gml
44+
```yaml
45+
- name: densify
46+
algorithm: qgis:densifygeometriesgivenaninterval
47+
params:
48+
- type: vector
49+
name: polys.gml
50+
- 2 # Interval
51+
results:
52+
OUTPUT:
53+
type: vector
54+
name: expected/polys_densify.gml
55+
```
5256

5357
Params and results
5458
------------------
@@ -57,17 +61,21 @@ Params and results
5761

5862
Params and results are specified as lists or dictionaries:
5963

60-
params:
61-
INTERVAL: 5
62-
INTERPOLATE: True
63-
NAME: A processing test
64-
64+
```yaml
65+
params:
66+
INTERVAL: 5
67+
INTERPOLATE: True
68+
NAME: A processing test
69+
```
70+
6571
or
6672

67-
params:
68-
- 2
69-
- string
70-
- another param
73+
```yaml
74+
params:
75+
- 2
76+
- string
77+
- another param
78+
```
7179

7280
### Layer type parameters
7381

@@ -80,13 +88,15 @@ You will often need to specify layers as parameters. To specify a layer you will
8088

8189
This is what it looks like in action:
8290

83-
params:
84-
PAR: 2
85-
STR: string
86-
LAYER:
87-
type: vector
88-
name: polys.gml
89-
OTHER: another param
91+
```yaml
92+
params:
93+
PAR: 2
94+
STR: string
95+
LAYER:
96+
type: vector
97+
name: polys.gml
98+
OTHER: another param
99+
```
90100

91101
### Results
92102

@@ -96,9 +106,11 @@ Results are specified very similar.
96106

97107
It couldn't be more trivial
98108

109+
```yaml
99110
OUTPUT:
100111
name: expected/qgis_intersection.gml
101112
type: vector
113+
```
102114

103115
#### Vector with tolerance
104116

@@ -114,41 +126,49 @@ field name `__all__` which will apply a certain tolerance to all fields.
114126
There is another property `geometry` which also accepts a `precision` which is
115127
applied to each vertex.
116128

117-
OUTPUT:
118-
type: vector
119-
name: expected/abcd.gml
120-
compare:
121-
fields:
122-
__all__:
123-
precision: 5 # compare to a precision of .00001 on all fields
124-
A: skip # skip field A
125-
geometry:
126-
precision: 5 # compare coordinates with a precision of 5 digits
129+
```yaml
130+
OUTPUT:
131+
type: vector
132+
name: expected/abcd.gml
133+
compare:
134+
fields:
135+
__all__:
136+
precision: 5 # compare to a precision of .00001 on all fields
137+
A: skip # skip field A
138+
geometry:
139+
precision: 5 # compare coordinates with a precision of 5 digits
140+
```
127141

128142
#### Raster files
129143

130144
Raster files are compared with a hash checksum. This is calculated when you create
131145
a test from the processing history.
132146

133-
OUTPUT:
134-
type: rasterhash
135-
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
147+
```yaml
148+
OUTPUT:
149+
type: rasterhash
150+
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
151+
```
136152

137153
#### Files
138154

139155
You can compare the content of an ouptut file by an expected result reference file
140156

141-
OUTPUT_HTML_FILE:
142-
name: expected/basic_statistics_string.html
143-
type: file
157+
```yaml
158+
OUTPUT_HTML_FILE:
159+
name: expected/basic_statistics_string.html
160+
type: file
161+
```
144162

145163
Or you can use one or more regular expressions that will be [matched](https://docs.python.org/2/library/re.html#re.search) against the file
146164
content
147165

148-
OUTPUT:
149-
name: layer_info.html
150-
type: regex
151-
rules:
152-
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
153-
- 'Geometry: Line String'
154-
- 'Feature Count: 6'
166+
```yaml
167+
OUTPUT:
168+
name: layer_info.html
169+
type: regex
170+
rules:
171+
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
172+
- 'Geometry: Line String'
173+
- 'Feature Count: 6'
174+
```

0 commit comments

Comments
 (0)
Please sign in to comment.