Skip to content

Commit

Permalink
test: update tests to suit
Browse files Browse the repository at this point in the history
Drop mention of IDs; they're just obfuscating the expectation of the tests
  • Loading branch information
agoose77 committed Nov 20, 2024
1 parent 230b901 commit 90e6f2a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 152 deletions.
228 changes: 76 additions & 152 deletions packages/myst-execute/tests/execute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,15 @@ cases:
value: this will break, but shouldn't be executed
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: print('abc')
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
- type: outputs
children:
- type: output
children: []
after:
type: root
children:
Expand All @@ -53,28 +45,22 @@ cases:
value: this will break, but shouldn't be executed
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: print('abc')
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- output_type: stream
name: stdout
text: |
abc
- type: outputs
children:
- type: output
# We lose the ID information, as it's not generated
data:
output_type: stream
name: stdout
text: |
abc
children: []

- title: tree with inline expression is evaluated
before:
type: root
Expand Down Expand Up @@ -114,206 +100,144 @@ cases:
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: print('abc')
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- type: outputs
children:
- type: output
data:
children: []
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- type: outputs
children:
- type: output
data:
children: []
after:
type: root
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: print('abc')
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- output_type: stream
name: stdout
text: |
abc
- type: outputs
children:
- type: output
data:
output_type: stream
name: stdout
text: |
abc
- type: block
kind: notebook-code
data:
id: nb-cell-0
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- output_type: error
# Note this traceback can be different on various machines
# Not including it means we still validate an error, just don't care about the traceback
# traceback:
# - "\e[0;31m---------------------------------------------------------------------------\e[0m"
# - "\e[0;31mValueError\e[0m Traceback (most recent call last)"
# - "Cell \e[0;32mIn[2], line 1\e[0m\n\e[0;32m----> 1\e[0m \e[38;5;28;01mraise\e[39;00m \e[38;5;167;01mValueError\e[39;00m\n"
# - "\e[0;31mValueError\e[0m: "
ename: ValueError
evalue: ''
- type: outputs
children:
- type: output
data:
output_type: error
# Note this traceback can be different on various machines
# Not including it means we still validate an error, just don't care about the traceback
# traceback:
# - "\e[0;31m---------------------------------------------------------------------------\e[0m"
# - "\e[0;31mValueError\e[0m Traceback (most recent call last)"
# - "Cell \e[0;32mIn[2], line 1\e[0m\n\e[0;32m----> 1\e[0m \e[38;5;28;01mraise\e[39;00m \e[38;5;167;01mValueError\e[39;00m\n"
# - "\e[0;31mValueError\e[0m: "
ename: ValueError
evalue: ''
- title: tree with bad executable code and `raises-exception` is evaluated and passes
before:
type: root
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
tags: raises-exception
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- type: outputs
children:
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
after:
type: root
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
tags: raises-exception
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- output_type: error
# Note this traceback can be different on various machines
# Not including it means we still validate an error, just don't care about the traceback
# traceback:
# - "\e[0;31m---------------------------------------------------------------------------\e[0m"
# - "\e[0;31mValueError\e[0m Traceback (most recent call last)"
# - "Cell \e[0;32mIn[2], line 1\e[0m\n\e[0;32m----> 1\e[0m \e[38;5;28;01mraise\e[39;00m \e[38;5;167;01mValueError\e[39;00m\n"
# - "\e[0;31mValueError\e[0m: "
ename: ValueError
evalue: ''
- type: outputs
children:
- type: output
data:
output_type: error
# Note this traceback can be different on various machines
# Not including it means we still validate an error, just don't care about the traceback
# traceback:
# - "\e[0;31m---------------------------------------------------------------------------\e[0m"
# - "\e[0;31mValueError\e[0m Traceback (most recent call last)"
# - "Cell \e[0;32mIn[2], line 1\e[0m\n\e[0;32m----> 1\e[0m \e[38;5;28;01mraise\e[39;00m \e[38;5;167;01mValueError\e[39;00m\n"
# - "\e[0;31mValueError\e[0m: "
ename: ValueError
evalue: ''
- title: tree with bad executable code and `skip-execution` is not evaluated
before:
type: root
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
tags: skip-execution
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- type: outputs
children:
- type: output
data:
after:
type: root
children:
- type: block
kind: notebook-code
data:
id: nb-cell-0
tags: skip-execution
identifier: nb-cell-0
label: nb-cell-0
html_id: nb-cell-0
children:
- type: code
lang: python
executable: true
value: raise ValueError
identifier: nb-cell-0-code
enumerator: 1
html_id: nb-cell-0-code
- type: output
id: T7FMDqDm8dM2bOT1tKeeM
identifier: nb-cell-0-output
html_id: nb-cell-0-output
data:
- type: outputs
children:
- type: output
data:
1 change: 1 addition & 0 deletions packages/myst-execute/tests/run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ casesList.forEach(({ title, cases }) => {
expect.arrayContaining([expect.stringMatching(throws)]),
);
}
console.log(JSON.stringify(after, null, 2));
expect(before).toMatchObject(after);
},
{ timeout: 30_000 },
Expand Down

0 comments on commit 90e6f2a

Please sign in to comment.