diff options
| author | Justin Mayer <entroP@gmail.com> | 2021-11-03 11:06:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-03 11:06:42 -0500 |
| commit | db49b9b1b5bafd59dcf547c2ab66da8f5cc730cd (patch) | |
| tree | 0d23c52f7a8cacbea6ceb91b4ef4ba2d12005cd8 /tests/usage_example.py | |
| parent | a9f544666f0146110a58c6b46fa60f4eb78f7a46 (diff) | |
| parent | 8bcc4d9119ed36c45ed7c2c68ac9aa5ab9c53ec2 (diff) | |
| download | feedgenerator-master.tar.gz | |
Merge pull request #32 from venthur/update_testsmaster
Modernize tests
Diffstat (limited to 'tests/usage_example.py')
| -rw-r--r-- | tests/usage_example.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/usage_example.py b/tests/usage_example.py new file mode 100644 index 0000000..043f8ce --- /dev/null +++ b/tests/usage_example.py @@ -0,0 +1,30 @@ +import os +import tempfile +import feedgenerator + +feed = feedgenerator.Rss201rev2Feed( + title="Poynter E-Media Tidbits", + link="http://www.poynter.org/column.asp?id=31", + description="""A group Weblog by the sharpest minds in online media/journalism/publishing. + Umlauts: äöüßÄÖÜ + Chinese: 老师是四十四,是不是? + Finnish: Mustan kissan paksut posket. (ah, no special chars) Kärpänen sanoi kärpäselle: tuu kattoon kattoon ku kaveri tapettiin tapettiin. + """, + language="en", +) +feed.add_item( + title="Hello", + link="http://www.holovaty.com/test/", + description="Testing." +) + +FN_PREFIX = 'feed_py3-' + +# Usage example in feedgenerator docs opens the file in text mode, not binary. +# So we do this here likewise. +fd, filename = tempfile.mkstemp(prefix=FN_PREFIX, suffix='.txt', text=True) +try: + fh = os.fdopen(fd, 'w') + feed.write(fh, 'utf-8') +finally: + fh.close() |
