GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gpython/py/tests/file.py at main · go-python/gpython

Expand file tree

/

file.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (37 loc) · 1.04 KB
/

file.py

Copy path

File metadata and controls

53 lines (37 loc) · 1.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 2018 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
from libtest import assertRaises
doc = "open"
assertRaises(FileNotFoundError, open, "not-existent.file")
assertRaises(IsADirectoryError, open, ".")
f = open(__file__)
assert f is not None
doc = "read"
b = f.read(12)
assert b == '# Copyright '
b = f.read(4)
assert b == '2018'
b = f.read()
assert b != ''
b = f.read()
assert b == ''
doc = "readline"
f2 = open(__file__)
line = f2.readline()
assert line == '# Copyright 2018 The go-python Authors. All rights reserved.\n'
f2.close()
doc = "write"
assertRaises(TypeError, f.write, 42)
# assertRaises(io.UnsupportedOperation, f.write, 'hello')
import sys
n = sys.stdout.write('hello')
assert n == 5
doc = "close"
assert f.close() == None
assertRaises(ValueError, f.read, 1)
assertRaises(ValueError, f.write, "")
assertRaises(ValueError, f.flush)
# closing a closed file should not throw an error
assert f.close() == None
doc = "finished"
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.